Best answer

Unable to post custom fields data to my zapier app

  • 17 September 2020
  • 1 reply
  • 226 views

Userlevel 1

I’m adding custom fields to my action form( through CLI).

here is the Working code.

const custom_fields_arr = (z, bundle) => {
  var email=encodeURIComponent(bundle.authData.email);
  const response = z.request('https://myURL/custom_fields/'+email);
  // json  is [{"custom_fields[5]":"field_name"},{"custom_field[14]":"field_name"}]

//here custom_field[5],custom_field[14] =>5,14 is the custom_field id from database
  return response.then(res => res.json);
};

and i’m able to generate custom field successfully.

but the problem is when i tried to pass this value(along with forms other value) i’m not able to get bundle.inputData.custom_field because of ‘[]’ parentheses, how can i post this data.

icon

Best answer by Zane 18 September 2020, 23:04

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 7
Badge +9

Not sure I follow the entirety of how your dynamic field definitions are coming back from your API, or how you need to format the data in the body of your POST request to your API in your action.  But I think the most pressing issue here is that `custom_fields[5]` is not a valid javascript variable name. So if you try to reference it with dot notation, it’s going to fail. Any reference to `bundle.inputData.custom_fields[5]` will error.  You could instead reference this like `bundle.inputData[‘custom_fields[5]’]`.

Other tips, be sure the field objects you generate conform to the field schema documented here: https://zapier.github.io/zapier-platform-schema/build/schema.html

 

For an example of ways to access and work with your dynamic fields in a dynamic way check out this recent thread and my response there: 

(this is a clickable link ^^)