Skip to main content

I have a trigger, which returning ar array of custom fields. each element of the array have a two keys FIELD_VALUE and FIELD_NAME.

When I am mapping these fields in an action there are only two field available :

  1. FIELD VALUES ==> comma(,) separated values of all custom fields key FIELD_VALUE, similarly
  2. FIELD NAMES ==> comma(,) separated values of all custom fields key FIELD_NAMES

I want to convert all of the fields in a key:value pair. So the value of FIELD_NAME will be a key and value of FIELD_VALUE will be a value.

screenshot-zapier.com-2019.09.02-16_38_38.png


I have tried to use code by zapier but it is not working as expected:

Here is my JS code:

var names = (inputData.names).split(',');

var values = ((inputData.values).toString()).split(',');

var obj = names.reduce((obj, key, index) => ({ ...obj, =key]: valuesbindex] }), {});

Screenshot from 2019-09-02 16-51-50.pngThe problem is null values, Zapier removing null values from comma (,) separated string.



could you loop through and convert nulls to empty strings ("") ? would that change behavior?



Yes we can but the problem is inputData.values missing null values. null values are not available at In inputData.values



ah, gatcha. yeah not sure if that is fixable at that point. I think it needs to be fixed prior to the trigger (i.e. at the source). zapier really needs to improve how it treats line items



@codetycon and @Openside do you have suggestions on what specifically Zapier can change to improve line item handling? How would you prefer to have this function? I'd really love to help flush this out with y'all so I can pass this along to the product team responsible for improvements here. Let me know!



@jesse Can we have a raw json too along with the current response from trigger? if raw json is available then we can manipulate it accordingly using code by Zapier and can use in the next actions.




@codetycon @jesse I think it's a good way to have a RAW JSON because sometimes we need to manipulate trigger's response before passing it to the action. In case of custom fields, line items, multiple addresses [Work,Home,Mobile] we need to apply some formulas or logic before using them in a action. I'm not sure if it is an optimized solution or not, #Zapier development team can suggest an better way to handle this.










@codetycon and @sudesh gotcha, so you would like to have raw JSON available for ANY trigger then? Just trying to think through this a bit as we're trying to strike a balance of giving technical tools to advanced users but not to scare off beginners, either. Any recommendations on how we might be able to strike the balance there?



Hey folks, Brian Cooksey here from the Zapier engineering team. I thought I'd chime in to give a little more context. Regarding the raw JSON, that's an interesting one. Awhile back we had thought about offering something like {{__output_raw}} as a way to say "give me everything from this step in the Zap." Would that cover the usecase you have in mind where you want to parse that with code?

As for the line items, that one has a complicated history. Our platform has gone through several iterations. If you are trying to build a Zap using an app built on the original platform, then yes, you get unwanted behavior with commas. The reason we can't simply fix that one is that it would be a major breaking change to lots of apps and lots of pre-existing Zaps.

The good news is that as the Platform has evolved, we've fixed this oversight with line items. Thus, if you go create a new app today, the structure returned from the trigger should be preserved, commas and all, so that any Action receiving the data will have it as intended.



good to know @cooksey . thanks. and yes, a {{__output_raw}} would be very useful, but would always want it for each step. like {{__output_raw_step4}} - this would be helpful when sending data to a webhook to avoid having to create all the postfields in the webhook.



@cooksey I encountered in the same issue when getting a matter details from Practice partner,

I notice you mention that you fixed this issue, and I need to create new app, can you elaborate what do you mean by creating new app?

I created a new zap with Practice partner step that find a matter, but I still see all the custom fields in one long line with comma separator.

I cant match each name to the value since I have "null"s in it.

Any help will be appreciated.



@Rotem what @cooksey was talking about was creating an app on the Zapier developer platform. The issues needs to be corrected before it gets to the Zap level.

If you don't have that as an option (I'm guessing you mean practice panther which does have an API so it is possible for you to build a private app on the Zapier platform that uses the new method of dealing with commas.)

However, @cooksey I'm not so sure the null value problem has been fixed as shown here: https://community.zapier.com/discussion/389/how-to-deal-with-a-null-value-in-a-line-item this is with my own private app for Quickbooks and it's still ignoring null values in line items. I'm not sure this is a comma issue. And I assume it's the same thing @Rotem has experienced.



@Rotem - @PaulKortman is correct, I meant creating a new app on our Platform, which you could then build Zaps with. If you didn't create the original Practice Partner, though, that's probably not feasible as you would have to re-integrate to their API yourself. You'll likely have to wait until that partner upgrades.


@PaulKortman regarding that other question, I'll follow up there.