Rachit sharma
Rachit sharma

Reputation: 21

How to make dynamic fields in zapier platform?

I want to make dynamic fields in Zapier platform. If a user chooses "Yes", then 4-5 fields are displayed, otherwise not. I have seen this type of example in ZOHO CRM integration where only 2 fields are shown at first.

There are only 2 fields now. When we choose "standard" in the first field, many fields are shown/open. Here are all the fields that show up

Similar to this, I want a field in which there are two options, "Yes" and "No". If user select Yes, then 4-5 fields should open (otherwise not). The user can use the fields to send data.

Upvotes: 1

Views: 2064

Answers (1)

xavdid
xavdid

Reputation: 5262

There's documentation about this process here (copied below)

const recipeFields = (z, bundle) => {
  const response = z.request('http://example.com/api/v2/fields.json');
  // json is is [{"key":"field_1"},{"key":"field_2"}]
  return response.then(res => res.json);
};

const App = {
  //...
  creates: {
    create_recipe: {
      //...
      operation: {
        // an array of objects is the simplest way
        inputFields: [
          {
            key: 'title',
            required: true,
            label: 'Title of Recipe',
            helpText: 'Name your recipe!'
          },
          {
            key: 'style',
            required: true,
            choices: { mexican: 'Mexican', italian: 'Italian' }
          },
          recipeFields // provide a function inline - we'll merge the results!
        ],
        perform: () => {}
      }
    }
  }
};

In your case, you'll replace the style field with your yes/no. The recipeFields function will have an if statement that checks the value of bundle.inputData.style and either returns more field objects or [], depending if more fields should be shown.

Upvotes: 1

Related Questions