Skip to main content
Best answer

Unable to post custom fields data to my zapier app

  • September 17, 2020
  • 1 reply
  • 234 views

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.

Best answer by ZaneBest answer by Zane

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 ^^)

View original
Did this topic help you find an answer to your question?
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

Forum|alt.badge.img+9
  • Zapier Staff
  • 331 replies
  • Answer
  • September 18, 2020

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 ^^)