Dynamic Input Field Management in Zapier Trigger Forms

I’m working on a Zapier integration and I’m stuck with a tricky part. Here’s what I’m trying to do:

  • There’s a hidden trigger in my form with a dropdown menu
  • I want the form to add new dropdowns based on what’s picked in the first one

I’ve been digging around but can’t figure out how to change the operation.inputFields on the fly. I’ve looked at the bundle and other stuff, but no luck so far.

Here’s a bit of what I’ve got:

const getInputFields = (z, bundle) => {
  const fields = [
    {key: 'projectType', type: 'string', label: 'Project Type'},
 ];
  
  if (bundle.inputData.projectType === 'special') {
    fields.push({key: 'extraInfo', type: 'string', label: 'Extra Info'});
  }
  
  return fields;
};

Any ideas on how to make this work? Thanks a bunch!

hey ryan, i’ve dealt with this before. try using the dynamicFields property in your trigger definition. it lets u define a function that returns fields based on previous inputs. something like:

dynamicFields: (z, bundle) => {
  if (bundle.inputData.projectType === 'special') {
    return [{key: 'extraInfo', type: 'string', label: 'Extra Info'}];
  }
  return [];
}

this should give u the dynamic behavior ur after. good luck!

I’ve encountered this issue before, and there’s a solution that might work for you. Instead of modifying operation.inputFields directly, you can leverage Zapier’s built-in functionality for dynamic fields.

Try restructuring your code like this:

const getInputFields = (z, bundle) => [
  {key: 'projectType', type: 'string', label: 'Project Type', altersDynamicFields: true},
  function(z, bundle) {
    if (bundle.inputData.projectType === 'special') {
      return {key: 'extraInfo', type: 'string', label: 'Extra Info'};
    }
    return [];
  }
];

This approach uses a function within the inputFields array to conditionally return fields based on the user’s selection. The altersDynamicFields property on the first field is crucial - it tells Zapier to re-evaluate the fields when that value changes.

Remember to test thoroughly, as dynamic fields can sometimes be tricky to get right. Good luck with your integration!

I’ve faced a similar challenge with dynamic fields in Zapier, and I can share what worked for me. Instead of trying to modify operation.inputFields directly, I found success using the dynamic property for fields that need to change based on user input.

Here’s an approach that might help:

const getInputFields = (z, bundle) => {
  return [
    {key: 'projectType', type: 'string', label: 'Project Type'},
    {
      key: 'dynamicField',
      type: 'string',
      label: 'Dynamic Field',
      dynamic: 'dynamic_dropdown.id.name',
      altersDynamicFields: true
    }
  ];
};

const performDynamicDropdown = (z, bundle) => {
  if (bundle.inputData.projectType === 'special') {
    return [{id: 'extra', name: 'Extra Info'}];
  }
  return [];
};

// In your App definition
{
  // ... other app details
  triggers: {
    // ... your trigger
    operation: {
      inputFields: getInputFields,
      performList: performDynamicDropdown
    }
  }
}

This approach lets Zapier handle the dynamic nature of the fields. The altersDynamicFields property is key here - it tells Zapier to re-run the field definitions when this field changes. Hope this helps!