Im building a Zapier App using the Zapier CLI.
I have created 2 dynamic input fields, both populated from an API.
Field 2 (channelId) is dependent on the choice in field 1 (appId).
inputFields: [
{
key: 'appId',
label: 'App',
required: true,
type: 'text',
helpText: 'Choose the App',
dynamic: 'app.id.display_name',
altersDynamicFields:true,
},
{
key: 'channelId',
label: 'Channel',
required: true,
type: 'string',
helpText: 'Choose the Channel',
dynamic: 'channel.channel',
}
]
This works fine the first time the user makes choices.
However, if they choose both options, and then change field 1 (appId) it does not clear the selection in Field 2 (channelId)
If you re open the menu, you see the new choices - so the perform function is running in the resource, but the previous selected value is not cleared - leaving an invalid selection.
How do you ensure that the dependent field is cleared when the field that alters it is changed?
Great question! The
altersDynamicFieldsproperty is a confusingly-named one. It's tied to custom/dynamic fields, where fields are added and removed from the form dynamically. BecausechannelIdis always present, it doesn't get recalculated whenappIdis changed.As a solution, you could make
channelIda custom field. It'll always be there, but it'll be properly invalidated (I think) whenappIdchanges: