2

我正在使用 Zapier CLI 构建一个 Zapier 应用程序。

我创建了 2 个动态输入字段,均由 API 填充。

字段 2 ( channelId) 取决于字段 1 ( appId) 中的选择。

inputFields: [
 { 
    key: 'appId',
    label: 'App',
    required: true, 
    type: 'text', 
    helpText: 'Choose the App', 
    dynamic: 'app.id.display_name',
    altersDynamicFields:true,
  },
  {
    key: 'channelId',
    label: 'Channel',
    required: true,
    type: 'string',
    helpText: 'Choose the Channel',
    dynamic: 'channel.channel',
  }
]

这在用户第一次做出选择时效果很好。

但是,如果他们选择这两个选项,然后更改字段 1 ( appId),则不会清除字段 2 ( channelId)中的选择

如果您重新打开菜单,您会看到新的选择 - 因此该perform函数正在资源中运行,但之前选择的值不会被清除 - 留下无效的选择。

当改变它的字段被更改时,如何确保清除依赖字段?

4

1 回答 1

0

好问题!该altersDynamicFields物业是一个令人困惑的名称。它与自定义/动态字段相关联,在表单中动态添加和删除字段。因为始终存在,所以在更改channelId时不会重新计算。appId

作为一种解决方案,您可以创建 channelId一个自定义字段。它会一直存在,但是当发生变化时它会被正确地失效(我认为appId

inputFields: [
 { 
    key: 'appId',
    label: 'App',
    required: true, 
    type: 'text', 
    helpText: 'Choose the App', 
    dynamic: 'app.id.display_name',
    altersDynamicFields:true,
  },
  // functions are re-run when fields with `altersDynamicFields: true` are changed
  () => [{
    key: 'channelId',
    label: 'Channel',
    required: true,
    type: 'string',
    helpText: 'Choose the Channel',
    dynamic: 'channel.channel',
  }]
]
于 2021-07-16T18:06:25.253 回答