javascript - Zapier - 为什么bundle.inputData的格式与inputFields不同?嵌套子项添加两次

标签 javascript node.js zapier

我们有一个 Zapier 应用程序,它有一个“createContact”操作。我已经通过 inputFields 数组定义了用户将在 Zapier 的 UI 中看到的字段。这包括一些嵌套在字段中的字段。

我的代码生成了所需的 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', 子项: [ { key: 'abc' } ] }

通过将 z.console.log(bundle.inputData) 放入 createContact 函数中,您可以看到 Children 数组中的键(即 startDate、school 等)已添加到2个地方:

== 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: 'test@test.com' }
== Version
1.0.0
== Step
7f944f0f-fd96-4ad3-bbc2-1d11b9b15c6f
== Timestamp
2018-01-15T12:09:56-06:00

根据the Zapier docs :

bundle.inputData is user-provided data for this particular run of the trigger/search/create, as defined by the inputFields.

所以我希望bundle.inputData与inputFields具有相同的格式。有什么想法可以让bundle.inputData采用我在inputFields中定义的格式吗?

谢谢:)

最佳答案

bundle.inputData 用于存储数据。 您需要将其添加到您的执行部分中:

名字:bundle.inputData.firstname

每当用户提供“名字:”时,它将使用bundle.inputData存储在名字中。

关于javascript - Zapier - 为什么bundle.inputData的格式与inputFields不同?嵌套子项添加两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48269250/

相关文章:

javascript - 使用 zapier 创建链接数组

javascript - Kendo UI Mobile 与 Google Adsense

javascript - 为什么 Node.js 每个进程旋转 7 个线程

javascript - 如何定义 "constant"并在 NodeJS 中随处访问它

javascript - 有没有办法检测特定消息的消息 react ?

javascript - 简单计数命令出现类型错误

javascript - 检查字符串不为空 - Zapier Javascript - 返回备用值

javascript - 在React中进行基于角色的路由时,使用switch语句并根据角色显示不同的组件是否存在安全问题?

javascript - jQuery if 语句字符计数

javascript - 在没有 ArrayController 的情况下对 hasMany 关系进行排序