Skip to main content

Integration & Automation-initiate process after form submission

This case is from Jing, a three-party developer 」

1. Usage scenarios

When new employees enter the company, they all need to apply for and collect personal assets. So how can we automatically apply for personal assets after filling in the information of new employees? The connector can be triggered when the form is submitted and automatically initiates a new process. Let's take a look at how to implement it!

2. Implement functions

2.1 Common forms (excluding sub-tables)

(1) trigger form

When this form is submitted, the integration automation initiation process is triggered.

(2) flow chart

(3) configuration Integration & Automation

(4) effect

2.2 Common forms (including sub-tables and excluding special processing of sub-tables)

(1) trigger form

(2) flow chart

(3) configuration Integration & Automation

(4) effect

2.3 Common forms (special processing with sub-tables and sub-tables)

(1) trigger form

(2) flow chart

(3) configuration Integration & Automation


    var result = [];  //定义新数组
var itemMap = {}; // 使用对象作为映射来提高查找效率
// 数组去重合并汇总
for (var i = 0; i < value.length; i++) {
var curr = value[i];
// textField_lptdo3ge为物品名称组件唯一标识
var key = curr.textField_lptdo3ge;
// 如果在映射中找到了对应的key,进行累加
if (itemMap.hasOwnProperty(key)) {
// 确保转换为数值类型再相加,textField_lptdo3ge为申请数量组件唯一标识
itemMap[key].numberField_lpterb46 = parseFloat(itemMap[key].numberField_lpterb46) + parseFloat(curr.numberField_lpterb46);
} else {
// 如果没有找到,复制对象并添加到映射和结果数组中
var copiedCurr = {};
for (var prop in curr) {
if (curr.hasOwnProperty(prop)) {
copiedCurr[prop] = prop === 'numberField_lpterb46' ? parseFloat(curr[prop]) : curr[prop];
}
}
result.push(copiedCurr);
itemMap[key] = copiedCurr;
}
}
// 处理数据格式 注意修改子表单内组件唯一标识
var newResult = result.map(function (item) {
return {
selectField_lptdo3gd: item.selectField_lptdo3gd,
textField_lptdo3ge: item.textField_lptdo3ge,
numberField_lptes9o2: item.numberField_lpterb46,
textField_lptes9o3 : item.selectField_lptdo3gd + "-" +item.textField_lptdo3ge,
};
});
// 输出处理后的结果
outputs.add("处理后数据","newResult",JSON.stringify(newResult));


// 处理数据格式  注意修改子表单内组件唯一标识
// key为目标流程表子表单组件唯一标识,value为当前表子表单组件唯一标识
var newResult = value.map(function (item) {
return {
selectField_lptdo3g1: item.selectField_lptdo3gd,
textField_lptdo3g2: item.textField_lptdo3ge,
numberField_lptes9o3: item.numberField_lpterb46,
textField_lptes9o4 : item.selectField_lptdo3gd + "-" +item.textField_lptdo3ge,
};
});
outputs.add("处理后数据","newResult",JSON.stringify(newResult));


// 处理数据格式  注意修改子表单内组件唯一标识
var filteredItems = value.filter(function (item) {
// 只返回物品名称为笔记本的数据
return item.textField_lptdo3ge === '笔记本';
});
outputs.add("处理后数据","filteredItems",JSON.stringify(filteredItems));

(4) effect

3. Try it online

This doc is generated using machine translation. Any discrepancies or differences created in the translation are not binding and have no legal effect for compliance or enforcement purposes.
Copyright © 2024钉钉(中国)信息技术有限公司和/或其关联公司浙ICP备18037475号-4