I have made a trigger which is called in a dynamic field. My trigger needs data from input fields, can I pass this data when calling the trigger in my dynamic field?
Create an input field for the parameter on both the trigger/action that presents the dynamic drop down, and the trigger that populates the dynamic dropdown. Give both fields the same key value. Make them required. When the Zap Editor calls the trigger to populate the dynamic dropdown, the field will be available in bundle.inputData.yourfield
.
I did a little example to refresh my memory and make sure I’m giving you good info.
Here’s a demo of the end result.
Adding the parameter field in the trigger that populates the dropdown
Using the field (in the dummy trigger). Shows you can use the field like normal.
In an action that presents the dynamic dropdown, create the same input field:
When you configure the dynamic dropdown, you don’t need to do anything special. If the input fields have the same key, Zapier handles the field mapping/parameter passing for you.
Great question. This capability is not self-evident or well documented. Let me know if you found this example clear and if this gets you up and running.
Thanks Zane, great answer! But I see I was not very clear in my answer.
This is my input field, it calls my content_type trigger.
{
key: 'content_type_id',
label: 'Content Type',
required: true,
dynamic: 'content_type.id.title',
altersDynamicFields: true
}
This is my trigger:
if (content_type_kind.type == "post_type") {
content_type_field = {
id: content_type.id,
title: content_type.attributes.title
};
fields.push(content_type_field);
}
Now I want “post_type" to be a variable, but this variable shouldn’t be filled by user input. Just getting the data from where my input field calls it from.
Oh! I think I see. You have data in addition to id and title that you want to use once the user makes a selection in the dynamic dropdown?
If that’s the case, what a lot of folks do in that situation is to encode that data into the ‘id’ value and then parse it out in their request handler before sending it to their API. So something like id = id + ‘~~’ + post_type. Then when you reference it, split that value on the ‘~~’ to get the individual values. It’s not as elegant as we’d like, but it’s the best way to solve that problem today.
I’m still not 100% sure I understood your question correctly - if not let us know and I’ll keep trying to get you an answer that works.
That’s not what I meant either, I want to send parameters to my trigger. So with normal functions it would be content_type(param1, param2). Can I do this using the dynamic attribute in an input field?
No, the “dynamic” field attribute takes a very specific string that provides a directive to the Zap Editor to call another trigger, map input field values, and build and render a dropdown with the results.
If the parameters you need to pass are not contained in Input Fields, what you might look at is a dynamic field instead. Here you’re using a function that returns field definitions in place of a statically defined field definition. See https://platform.zapier.com/docs/input-designer#how-to-add-dynamic-and-custom-fields and https://zapier.github.io/zapier-platform/#customdynamic-fields. There’s recent examples and discussions of how to use these here in the community as well.
^ this example could also have been implemented as a dynamic dropdown, as that’s all the dynamic field is creating, but it demonstrates the usage.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.