Workflow: Pipedrive deal stage change triggers document generation with product details in Formstack Documents
I’m working on a zap that needs to create documents with product line items using Formstack’s loop functionality. The challenge is that Zapier splits all the product data into separate arrays by field name instead of keeping each product as a complete object.
Right now I have product information coming through as:
Product names in one array
Product codes in another array
Units, quantities, and categories all in separate arrays
Formstack Documents has a feature that can loop through product lists to create table rows, but it needs the data structured properly. I want to use a Python code step to reorganize this data before sending it to Formstack.
My plan is to take all these separate arrays and combine them back into proper product objects that Formstack can work with. Each product should have its name, code, unit, quantity and category grouped together.
Has anyone done something similar with restructuring Zapier data for document generation? I’m wondering if I should format everything in the code step and then use Formstack’s API directly, or just prepare the data structure and let Zapier handle the API call.
I’ve encountered this issue when setting up automated proposal workflows too. A handy approach is using Python’s zip function to reconstruct your product objects from the separate arrays Zapier generates. In your code step, you can iterate through the arrays with: products = [{'name': name, 'code': code, 'unit': unit, 'quantity': qty, 'category': cat} for name, code, unit, qty, cat in zip(names_array, codes_array, units_array, quantities_array, categories_array)]. Regarding the API, I recommend using Zapier’s built-in Formstack Documents action after you restructure the data. It’s more reliable in managing authentication and error handling compared to direct API calls. Just make sure to format the restructured product data as JSON strings when you send them to the Formstack action, as that’s what their loop functionality requires for handling complex objects.
Yeah, I’ve dealt with this headache too. Skip the array wrestling - build a dictionary first, then convert to JSON. Try product_dict = dict(zip(range(len(names)), zip(names, codes, units))) - works great for me. Heads up: Formstack’s loop feature is super picky about data types. Pass strings for quantities, not integers, or it’ll fail without telling you.
Hit this same issue building invoice workflows. Formstack Documents needs a specific JSON structure for loop merge tags. Don’t mess around with array manipulation - just create a nested dictionary where each product becomes an indexed object. Build something like {“products”: [{“name”: val1, “code”: val2}, {“name”: val3, “code”: val4}]} then stringify the whole thing before sending it to Formstack. Big gotcha: your field names must match your Formstack template merge tags exactly. Even tiny differences cause silent failures. Use Zapier’s native Formstack action instead of direct API calls - way better error reporting when stuff breaks.