Mainak
Mainak

Reputation: 470

Unable to set dynamic dropdown value in Zapier CLI trigger

I have my app in Zapier CLI. I have created a trigger to set dropdown values for a particular action step during zap creation. The data comes like this :

{ "data": {
    "account_status": {
                "field_name": "account_status",
                "field_label": "Status",
                "field_type": "list",
                "field_length": "50",
                "field_items": "Active|Inactive|444|Closed",
                "required": "0",
                "related_module": "",
                "related_field_name": "",
                "join_table": "",
                "join_lhs_field_name": "",
                "join_rhs_field_name": "",
                "related_data_field": ""
            },
      }
}

Here is my code: Now I am trying to set the data for the dynamic dropdown using field_items value from the above result like this:

return responsePromise
    .then(response => JSON.parse(response.content ) )
    .then(data => {
      const account_status_list = data.data.account_status.field_items;        
      const account_status_arr = account_status_list.split("|"); 
      return account_status_arr.map(function(e){
          e.id = e
          return e
      }) 
  })

my input field for the dynamic dropdown trigger is:

{
  key: 'account_status', 
  label:'Account Status', 
  required: false, 
  dynamic: 'account_status.account_dropdown.id'
}

On clicking the dropdown I get this error

Can anyone suggest where I am going wrong or what may I do to resolve this ?

Upvotes: 1

Views: 650

Answers (1)

xavdid
xavdid

Reputation: 5262

David here, from the Zapier Platform team.

The issue is that Zapier expects an array of objects and you're returning an array of strings. It seems like you're trying to make an id field in your code snippet, but calling "Active".id = "Active" won't make an object.

Instead, you should change your map function to be something like the following:

return account_status_arr.map(function(e){
    return {id: e}
})

The other thing you'll probably need to tweak is how your dynamic dropdown is set up. It's a period-separated string that follows the format trigger_key.id_key.label_key. The id and label can be the same key; it really depends on what data you need to send to the API (the label is just for show, the id is what's actually sent). In the dynamic field, you'll have a dyanmic property that'll be account_status.id.id.

There are docs here.

Upvotes: 2

Related Questions