通过API获取当前审批人邮箱地址

通过API获取当前审批人邮箱地址

需求描述:审批中的数据,需要精确通知到当前审批的用户,进行流程催办
实现方案:通过API接口获取当前审批人进行邮件通知,配置工作流调用函数触发,触发时机可以设置为‘提交审批后 xx 天’
函数代码:

//获取报价单主题
quote = zoho.crm.getRecordById("Quotes",id,{"approved":"both"});
name = quote.get("Subject");
info name ;
//通过API接口获取审批详情
approval_details = invokeurl
[
url :"https://www.zohoapis.com.cn/crm/v2.2/Quotes/" + id + "/actions/approval_details"
type :GET
connection:"cnuser"
];
approval_process = approval_details.get("approval_process");
for each  approval in approval_process
{
info "审批人信息:" + approval;
approval_status = approval.get("approval_status").get(0).get("status");
info "审批状态:" + approval_status;
//获取第1个状态是pending的用户,就是当前审批人
if(approval_status.contains("pending"))
{
approval_userid = approval.get("approver").get("resource").get("id");
approval_username = approval.get("approver").get("resource").get("name");
break;
}
}
info "当前审批人id:" + approval_userid;
info "当前审批人姓名:" + approval_username;
//根据用户id获取用户邮箱地址
searchList = zoho.crm.getRecordById("users",approval_userid);
useremail = searchList.get("users").get(0).get("email");
info useremail;
sendmail
from : zoho.adminuserid
to : useremail
subject: "【报价单审批操作提醒 - "+name+" 重要】"
message : "<div>"+approval_username+"您好,<br></div><div><br></div><div>报价单"+name+"已提交审批,正在等待您的审批,请尽快操作,谢谢!<br></div>"
]