0

I'm building a Zapier app for a platform that have dynamic fields. I have an API that returns the list of fields for one of my resource (for example) :

[
  { name: "First Name", key: "first_name", type: "String" },
  { name: "Civility", key: "civility", type: "Multiple" }
]

I build my action's inputFields based on this API :

create: {
  [...],
  operation: {
    inputFields: [
      fetchFields()
    ],
    [...]
  },
}

The API returns type that are list of values (i.e : Civility), but to get these values I have to make another API call.

For now, what I have done is in my fetchFields function, each time I encounter a type: "Multiple", I do another API call to get the possible values and set it as choices in my input field. However this is expensive and the page on Zapier takes too much time to display the fields.

I tried to use the z.dehydrate feature provided by Zapier but it doesn't work for input choices.

I can't use a dynamic dropdown here as I can't pass the key of the field possible value I'm looking for. For example, to get back the possible values for Civility, I'll need to pass the civility key to my API.

What are the options in this case?

rmonjo
  • 2,675
  • 5
  • 30
  • 37

1 Answers1

0

David here, from the Zapier Platform team.

Thanks for writing in! I think what you're doing is possible, but I'm also not 100% that I understand what you're asking.

You can have multiple API calls in the function (which it sounds like you are). In the end, the function should return an array of Field objects (as descried here).

The key thing you might not be aware of is that subsequent steps have access to a partially-filled bundle.inputData, so you can have a first function that gets field options and allows a user to select something, then a second function that runs and pulls in fields based on that choice.

Otherwise, I think a function that does 2 api calls (one to fetch the field types and one to turn them into Zapier field objects) is the best bet.

If this didn't answer your question, feel free to email partners@zapier.com or join the slack org (linked at the bottom of the readme) and we'll try to solve it there.

xavdid
  • 5,092
  • 3
  • 20
  • 32
  • Hey David, thx, I contacted the support and got this answer: "This is actually something we're actively working on right now. You'll be able to refer to the key of the field in the dynamic dropdown method. For now the only way of doing it would be to have each dynamic dropdown refer to a unique trigger key based on the values that you want back, but that probably requires you to know each type of those dropdowns in advance." – rmonjo Oct 09 '18 at 08:10