问题
Currently building a Zapier app but running into a blocker when trying to pass information from a dynamic dropdown.
Ideally, I want to be able to set an object of data to bundle.inputData
whenever someone selects an item. Thedocs only provide a single value solution, but wondering if anybody knows of a solution to this?
Example of the problem:
//User Data
[
{id:1, name: Tommy, email: tom@gmail.com},
{id:2, name: Bill, email: bill@gmail.com},
{id:3, name: Greg, email: greg@gmail.com}
]
//Input Field as part of the operation object
inputFields: [
{
key: 'users',
required: true,
label: 'Select user to notify',
dynamic: 'users.email.name',
},
]
Instead of passing back an email
when a user selects an item, I want to be able to send both name
and email
as part of the bundle.inputData
.
Any ideas would be greatly appreciated!
回答1:
Solution: Combine Name/Email as a string in trigger and separate when making final HTTP request.
Example:
const combineUserEmail = (name, email) => `${name}/${email}`;
const triggerUsers = async(z, bundle) =>{
const response = await z.request({
url: https://blahblah.com/users
});
const users = z.JSON parse(response.content);
const results = users.map((user, i) =>({id: i, user: combineUserEmail(item.name, item.email)})
}
来源:https://stackoverflow.com/questions/59740182/zapier-cli-dynamic-dropdown-how-to-set-multiple-values-to-bundle-inputdata