zapier - Zapier - Remove item from Line-Items object and/or output Line-items from Code step
问题描述
it's been several times that I got stuck with this one: I don't understand how to output Line-Items with a Code step?
Is it even possible?
For example:
- I build Line-Items from a JSON
- In these Line-Items, I would like to remove some of them, based on various criteria
- Then output Line-Items and use them in a further step
But, on a further step, I don't get Line-Items but separate values.
So, how to manipulate Line-Items into a Code step and get Line-Items as the output?
I feel like I'm missing something...
Thanks.
PS: more explanation on the "why".
I got my data from a Typeform entry in which I can get between 1 and 5 emails (plus other data) So, I got empty row that I want to remove That's why I build a Line-Items object then try to remove the useless ones
解决方案
Not sure if this is what you're looking for, but this is what I use. Given two line items, one with names and one with values, each separated by ;;, I combine those into one object, and then use the value of a field based on the name in a later action.
var names = inputData.names.split(";;");
var values = inputData.values.split(";;");
function toObject(names, values) {
var result = {};
for (var i = 0; i < names.length; i++)
result[names[i]] = values[i];
return result;
}
output = toObject(names,values);
推荐阅读
- docker - docker:当我只使用--tty 或-t(不带-i)以实现与--rm 一起的彩色输出时,docker 不会在 ctrl+c 上停止
- windows - 如何使用批处理脚本压缩多个文件夹
- c# - 请求的 QueryString 本地化区域性在具有 AJAX 请求的 ASP.NET Core Razor 页面模型中不起作用
- javascript - React.js/socket.io 瓶颈问题
- git - 合并后我需要做什么?
- android - 当键盘打开时,约束布局顶部视图会受到干扰指导百分比不起作用
- c# - “DataTable”不包含“GetEnumerator”的公共实例定义
- reactjs - reactjs redux axios prob with img upload (symf in back)
- react-native - OneSignal 推送令牌是否与应用 ID 相同?
- autohotkey - AutoHotKey 功能执行文件重命名而不依赖发送 F2 键代码