Dict keys as dropdown choices?

  • 27 February 2024
  • 0 replies

Userlevel 1

I am trying to develop an app using the Zapier CLI.

I have two input fields:

One is a key-value dictionary where the customer types the “name” of the attribute as key, and its value in the value field. The next input field is a multi-select dropdown where we want the customers to select all the fields that are “object” attributes, so we can parse them and make an API call as an object attribute instead of the default behaviour which is to convert, for example, the above JSON, into string.

Here is the code that I am using:

// ...
if (
bundle.inputData.other_attributes != null &&
) {
for (const [key, value] of Object.entries(
)) {
newBody['attributes'][key] = value;

// loop through values of object_attributes and match keys
if (bundle.inputData.object_attributes != null && bundle.inputData.object_attributes.length) {
for (i in bundle.inputData.object_attributes) {
if(bundle.inputData.object_attributes[i] in bundle.inputData.other_attributes) {
let key = bundle.inputData.object_attributes[i];
let jsonData = newBody['attributes'][key].replace(/\r\n|\n/g, "\\r\\n");

let data = JSON.parse(jsonData);
newBody['attributes'][key] = data;

I want the multi-select dropdown to automatically populate the keys (or attributes) that the customer has entered in the dict (first) input. For example:


First Input: { “key1”: “value1”, “key2”: “value2” }

Second Input choices: [“key1”, “key2”]


And then, if they add one more key-value pair:


First Input: { “key1”: “value1”, “key2”: “value2”, “key3”: “value3” }

Second Input choices: [“key1”, “key2”, “key3”]


0 replies

Be the first to reply!