问题描述
Zapier 代码文档说代码 zap 的输出可以是字典或字典列表(请参阅数据变量"部分:https://zapier.com/help/code-python/).
The Zapier code documentation says that the output of a code zap can be either a dictionary or a list of dictionaries (See "Data Variable" section: https://zapier.com/help/code-python/).
这样做时,
output = [{'Booking':'Shirt'},{'Booking':'Jeans'}]
代码的输出只返回第一个字典,但是:
the output of the code returns only the first dictionary, however:
runtime_meta__duration_ms: 2
runtime_meta__memory_used_mb: 22
id: [redacted]
Booking: Shirt
Fields with no value:
runtime_meta__logs
我在这里做错了什么?非常感谢!
What am I doing wrong here? Thanks a lot!
推荐答案
来自 Zapier 平台团队的 David 在这里.返回数组的代码步骤几乎没有记录(因为没有 UI 支持,而且很混乱,正如您所知).
David from the Zapier platform team here. Code steps returning an array is a mostly undocumented (because there's no UI support and it's confusing, as you can tell) feature.
测试时,它只会显示数组中的第一项.当它真正运行时,代码步骤之后的所有步骤都将为数组中的每个项目运行.任务历史将反映这一点
When testing, it'll only show the first item in the array. When it runs for real, all steps after the code step will run for each item in the array. The task history will reflect this
所以设置 zap 并打开它,它会像您期望的那样工作.
So set up the zap and turn on and it'll work like you expect.
抱歉给您带来的困惑,如果您有任何其他问题,请告诉我!
Sorry for the confusion and let me know if you have any other questions!
这篇关于如何在 Zapier 代码(Python)中正确返回字典列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!