【问题标题】:must not contain children and list, as they're mutually exclusive不得包含子项和列表,因为它们是互斥的
【发布时间】:2019-06-03 07:22:32
【问题描述】:

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

如果我将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.    

我真的很想拥有这样的配置。有什么解决办法吗?

【问题讨论】:

    标签: zapier zapier-cli


    【解决方案1】:

    好问题!来自 Zapier Engineering 的 Caleb。

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

    订单项(由子字段提供支持)非常适合用户从之前的步骤映射订单项。这些允许 Zaps 创建动态数量的对象 - 可能会创建 0 个或更多对象。当用户有一个 Zap 以下列形式从 Step 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'
        }]
    }]
    

    然后用户可以将步骤 A 中的 email_addresses.name 映射到步骤 B 的 email_addresses.type,并将步骤 A 中的 email_addresses.address 映射到步骤 B 的 email_addresses.address。启用 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"]
    }
    

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


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

    【讨论】:

      猜你喜欢
      • 2014-11-08
      • 2011-01-06
      • 2011-02-18
      • 1970-01-01
      • 2021-10-30
      • 1970-01-01
      • 2018-12-16
      • 2012-12-04
      • 2020-01-25
      相关资源
      最近更新 更多