根据工单信息获取CRM中订单信息,并回传到工单自定义字段中

根据工单信息获取CRM中订单信息,并回传到工单自定义字段中

1、示例场景:处理工单时能够查看到CRM中的订单信息

2、实现方法:将CRM订单号手动填写到工单自定义字段中,保存后触发工作流调用下面的函数抓取CRM信息

函数样例:
//获取desk工单信息
t = zoho.desk.getRecordById("41071068","tickets",id.toLong());
//获取订单号
oid = t.get("customFields").get("订单号");
//在CRM中搜索订单信息
orders = zoho.crm.searchRecords("Orders","(order_number:equals:" + oid + ")",1,200,"crm");
for each  order in orders
{
//定义变量
sumk = "";
sumi = "";
sums = "";
//获取CRM订单系统id
orid = order.get("id");
or = zoho.crm.getRecordById("Orders",orid,"crm");
pds = or.get("product_details");
//获取产品明细子表单信息,并进行拼接
for each  pd in pds
{
kw = pd.get("commodity_display_name");
inv = pd.get("commodity_repertory_sku");
sales = pd.get("commodity_sales");
sumk = kw + "," + sumk;
sumi = inv + "," + sumi;
sums = sales + "," + sums;
}
//信息赋值
m = Map();
m.put("产品关键字",sumk);
m.put("库存SKU",sumi);
m.put("销售负责人",sums);
mc = Map();
mc.put("customFields",m);
//更新工单
res = zoho.desk.update("41071068","tickets",id.toLong(),mc);
info res;
}

相关参数:
id:Ticket id