Question

Dynamic / custom fields passing to the api

  • 12 September 2020
  • 2 replies
  • 1055 views

I am using input fields and dynamic fields. I have been used array of object into dynamic fields code like  

var custom_fields=[{"key":"leadstest_cstm"},{"key":"leads_default_cstm"},{"key":"leads_default_currency_cstm"},{"key":"leads_default_numeric_cstm"},{"key":"lead_serial_cstm"},{"key":"offer_amount_cstm"},{"key":"pricelist_cstm"},{"key":"short_bio_cstm"}]

 

The dynamic fields are displaying along with input fields when i creating zaps. The problem is when i going to “Send data” and click on the “Retest action” for testing the input data is passing to the api which i have mentioned into the API configuration code and saving to our crm application but custom field’s data is not saving i.e custom fields data is not passing to the api.

 

consider the following sample code in api configuration:

 body: {
     'apiSecret': bundle.authData.apiSecret,
    'apiKey': bundle.authData.apiKey,
    
    "request":{
        'first_name':bundle.inputData.first_name,
     'last_name':bundle.inputData.last_name,
            
      
    
    },

According to the api requirements we have to pass all the data to the body and there is “request” array all the input data and custom data have to be pass through the “request” array within body.

The first_name and last_name fields are saving into our CRM application thorugh the api since these are passing through the “request” array.

My question is here when zappier is merging the custom fields with input fields are they passing in to the “request” array  ? I guess the custom fields  is not including in the “request” array or may be it is out side of body thats why api is not getting the custom fields value. So how do we include the “custom” fields into the “request” array as per aforementioned sample code? 

Basically when we declare the array of object into the dynamic field (using input designer) zapier will automatically merge with input fields but if we required to merge in our own  way how would we do that.? 

kindly provide sample code as an example so we can understand easily and solve the issue. Please advice.

 

Thanks & Regards

 


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

2 replies

Userlevel 7
Badge +9

You might have a look at this recent discussion. I think your question is similar: 

 

All of the fields will be in `bundle.inputData`.  Dynamic fields, those which you did not hard code, will need to be referenced dynamically, say with the Javascript spread operator, or some other similar mechanism.  

Note that to test that it’s best to jump directly to making a Zap, and having a look at the monitoring section of the UI.  The ability to enter test data for dynamic fields with the built-in UI test component is limited right now.

For an example of the use of the spread operator, you can see it in the doc :

https://platform.zapier.com/docs/input-designer#how-to-include-dynamic-fields-in-api-calls

body: { ...bundle.inputData }