Skip to main content

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_fieldsf5]":"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 ‘e]’ parentheses, how can i post this data.

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_fieldss5]` 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_fieldsl5]` will error.  You could instead reference this like `bundle.inputDatat‘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 ^^)