我们有一个Zapier应用程序,它具有“ createContact”操作。我已经定义了我们的用户将通过inputFields
数组在Zapier的用户界面中看到的字段。这包括嵌套在字段中的某些字段。
我的代码产生了所需的UI,但是当我创建一个zap并对其进行测试时,接收到的数据的格式不同。嵌套字段被添加两次。
这是导出的对象:
module.exports = {
key: 'contact',
noun: 'Contact',
create: {
display: {
label: 'Create Contact',
description: 'Creates a new contact.'
},
operation: {
inputFields: [
{key: 'firstName', required: true},
{key: 'lastName', required: true},
{key: 'middleNames', required: false},
{key: 'address', required: false},
{key: 'phoneNumbers', required: false},
{key: 'emails', required: false},
{key: 'tags', required: false},
{key: 'links', required: false},
{
key: 'education', children: [
{key: 'school', required: false},
{key: 'degree', required: false},
{key: 'program', required: false, label: 'Field of Study'},
{key: 'grade', required: false},
{key: 'startDate', required: false, type: 'datetime' },
{key: 'endDate', required: false, type: 'datetime' },
]
}
],
perform: createContact
},
},
sample: {
id: 1,
firstName: 'Test first name',
lastName: 'Test last name'
},
outputFields: [
{key: 'id', label: 'ID'},
{key: 'firstName', label: 'First Name'},
{key: 'lastName', label: 'Last Name'},
]
};
注意:我在Field Schema上关注了Zapier的文档,它表明这是必需的格式:
{ key: 'abc', children: [ { key: 'abc' } ] }
通过将
z.console.log(bundle.inputData)
放在createContact函数中,您可以看到children数组中的键(即startDate,school等)已添加到两个位置:== Log
inputData 2 { startDate: '15/01/2017',
school: 'ABC School',
endDate: '16/01/2017',
degree: 'Test degree',
firstName: 'Joe',
grade: '1st',
lastName: 'Bloggs',
program: 'Test program',
education:
[ { startDate: '2017-01-15T00:00:00+00:00',
school: 'ABC School',
endDate: '2017-01-16T00:00:00+00:00',
degree: 'Test degree',
grade: '1st',
program: 'Test program' } ],
emails: '[email protected]' }
== Version
1.0.0
== Step
7f944f0f-fd96-4ad3-bbc2-1d11b9b15c6f
== Timestamp
2018-01-15T12:09:56-06:00
根据the Zapier docs:
bundle.inputData
是用户为该特定的触发器/搜索/创建运行提供的数据,如inputFields所定义。因此,我希望bundle.inputData与inputFields具有相同的格式。有什么想法可以使bundle.inputData成为我在inputFields中定义的格式吗?
谢谢 :)
最佳答案
bundle.inputData用于存储数据。
您需要将其添加到您的表演部分:firstname: bundle.inputData.firstname
只要用户提供“名字:”,就会使用bundle.inputData
将其存储在名字中。