javascript - 由函数呈现时,在 inputData 中展开行项目
问题描述
我有需要在函数中呈现的动态子输入字段,但是当它们出现时,它们不会正确包含在 inputData 中/不在父输入字段的键下。当孩子直接包含在 inputFields 中时,它按预期工作,但我不能在 Zapier 的孩子数组中使用函数。
这是当前的inputData,当在函数中渲染行项目时,LI_表示它是一个子输入键-
"inputData": {
"supplier": "1",
"LI_budget": 1,
"LI_tax": 1,
"company": "1",
"currency": "1",
"LI_price": "1",
"LI_description": "1"
}
我期待(“父”是 inputField 父键):
"inputData": {
"supplier": "1",
"parent": [{
"LI_budget": 1,
"LI_tax": 1,
"LI_price": "1",
"LI_description": "1"
}],
"company": "1",
"currency": "1",
}
这是我用来拉入父子输入字段的函数:
const getLineItems = async (z, bundle) => {
let lineItem = {
key: 'parent',
children: [{
key: 'LI_description',
label: 'Description',
required: true
},
{
key: 'LI_budget',
required: true,
label: 'Budget',
dynamic: 'budget.id'
},
{
key: 'LI_price',
required: true,
type: 'number',
label: 'Unit price',
helpText: 'Example: 50.25'
},
{
key: 'LI_tax',
required: true,
label: 'Tax Rate',
dynamic: 'tax_rate.id'
},
]
}
return [lineItem];
};
我取出来简化的 getLineItems 函数中生成了动态字段。TIA
解决方案
来自 Zapier 平台支持的 Caleb。这是困难的一个!我们的平台上有一个长期存在的问题报告,用于支持带有parent
键的自定义字段(它归结为鸡与蛋的问题,当我阅读有关该问题的讨论时,这真的让我头晕目眩)。您的inputFields
功能是正确的,只需将其正确存储在我们的捆绑包中即可。
我认为我们可以拼凑出一个解决方法来解压它。不过,在我这样做之前,您能否在编辑器中对此进行测试,然后将上一步的实际订单项提交到此步骤?我不确定它是什么inputData
样子(例如,如果多个项目被拆分1,2,3
或以其他方式拆分)。如果您想对此进行迭代,最好切换到我们的公共开发人员 Slack ( http://zpr.io/ttvdr );然后我们可以在这里发布结果,以便下一个人遇到这个问题。
推荐阅读
- php - 从 php 中的 mySQL/PDO 查询分配变量
- json - Golang中的编组结构与地图
- javascript - 使用 react 开发时窗口焦点的变化
- java - 如何动态扩展差异父类?
- php - Android Rest API 监听数据库变化
- postgresql - Heroku 上的 Typeorm 部署
- docker - docker run 改变宿主机上文件夹的权限
- session - 会话变量在 Mac 中被重置
- python-3.x - 如何在ffmpeg中为文件指定随机名称
- duplicates - DB2 - 带有 DISTINCT 子句的 LISTAGG() - 不起作用?