2

我需要一个可以配置复杂对象数组的小部件,即带有标签的电子邮件地址。

如果我将 设置inputFields为具有此条目:

 {
    key: 'email_addresses', required: false, list: true, children: [{
      key: 'type', required: true, type: 'string'
    }, {
      key: 'email', required: true, type: 'string'
    }]
  }

我遇到以下错误zapier validate

Message  │ must not contain children and list, as they're mutually exclusive.    

我真的很希望能够拥有这种配置。有什么解决方法吗?

4

1 回答 1

0

好问题!来自 Zapier Engineering 的 Caleb。

我认为问题归结为您要实现的目标。列表非常适合用户希望为其指定多个值的静态字段。以 Trello 卡片标签为例;用户可能希望 Zap 创建一个带有Zapier标签的 Trello,以及带有上一步中的值的标签。

当用户从之前的步骤映射订单项时,订单项(由子字段提供支持)非常有用。这些允许 Zaps 创建动态数量的对象 - 可能会创建 0 个或更多对象。当用户有一个 Zap 以以下形式从步骤 A 返回数据时:

{
    "id": 42,
    "name": "Caleb McQuillin",
    "phone_numbers": [{
        "name": "work",
        "number": "314-159-2653"
    }],
    "email_addresses": [{
        "name": "work",
        "address": "caleb.mcquillin@example.com"
    }, {
        "name": "personal",
        "address": "caleb.mcquillin@example.net"
    }]
}

如果您使用以下设置您的操作inputFields

[{
    key: 'email_addresses',
    required: false,
    children: [{
        key: 'type',
        required: true,
        type: 'string'
    }, {
        key: 'email',
        required: true,
        type: 'string'
    }]
}]

然后,用户可以将email_addresses.name步骤 A 映射到email_addresses.type步骤 B,将步骤 A 映射email_addresses.addressemail_addresses.address步骤 B。启用 Zap 后,新条目可能有 0 个电子邮件地址、1 个电子邮件地址、100 个电子邮件地址等。您inputData将包含以下基于我之前的示例:

{
    "email_addresses": [{
        "type": "work",
        "email": "caleb.mcquillin@example.com"
    }, {
        "type": "personal",
        "email": "caleb.mcquillin@example.net"
    }]
}

如果您使用以下设置您的操作inputFields

[{
    key: 'email_address_types',
    list: true,
    required: true
}, {
    key: 'email_address_addresses',
    list: true,
    required: true
}]

用户将能够指定静态数量的电子邮件地址以从步骤 A 映射到步骤 B。如果步骤 A 返回的数据格式为

{
    "id": 42,
    "name": "Caleb McQuillin",
    "home_phone": null,
    "work_phone": "314-159-2653",
    "home_email": "caleb.mcquillin@example.net,
    "work_email": "caleb.mcquillin@example.com",
}

并且用户映射了家庭和工作电子邮件类型,您inputData将包含以下内容:

{
    "email_address_types": ["work", "personal"],
    "email_address_addresses": ["caleb.mcquillin@example.com", "caleb.mcquillin@example.net"]
}

并且您可能会使用脚本将它们压缩到一组对象中。


我希望所有这些都是有道理的!如果您对上述内容有任何疑问,请告诉我。:)

于 2019-01-09T19:40:26.147 回答