审批流脚本

一、创建审批流

二、配置审批流脚本

  • 流程实例初始化参数

{
    "processActionType": "start",
    "thirdPartyUniqueId": "esn3593333",
    "processEnd": false,
    "userPhone": "18810487612",
    "language": "zh_CN",
    "tenantCode": "developplatform_kuwm0ptf",
    "userName": "倪帅臣",
    "userId": "0f059088-9c92-4769-a3e7-8f1a341cc3df",
    "userCode": "HRC18810487612",
    "processDefinitionKey": "processcenter_c9dd2735",
    "mainTenantId": "kuwm0ptf",
    "businessKey": "05534be1_2684626243162368",
    "userMail": "nishch@yonyou.com",
    "tenantId": "kuwm0ptf_developplatform",
    "processInstId": "d8bf7e6d-a1ba-11ec-85c1-2e81ea54a0b4"
}
  • 流程完成参数

{
    "bpmCallbackRequestId": "2ad8e0422b1b4789aa9bf838f0ee5a7d",
    "processEnd": true,
    "userPhone": "18810487612",
    "canBeArchived": false,
    "language": "zh_CN",
    "source": "developplatform",
    "tenantCode": "developplatform_kuwm0ptf",
    "uuid": "2ad8e0422b1b4789aa9bf838f0ee5a7d",
    "userCode": "HRC18810487612",
    "processDefinitionKey": "processcenter_c9dd2735",
    "thirdPartyUniqueId": "esn3593333",
    "bpmCallbackRequestTs": 1647058453850,
    "userName": "倪帅臣",
    "userId": "0f059088-9c92-4769-a3e7-8f1a341cc3df",
    "mainTenantId": "kuwm0ptf_developplatform",
    "businessKey": "05534be1_2684626243162368",
    "userMail": "nishch@yonyou.com",
    "tenantId": "kuwm0ptf_developplatform",
    "processInstId": "d8bf7e6d-a1ba-11ec-85c1-2e81ea54a0b4",
    "yht_access_token": "bttR2lrVWlLdVI2bzhISXQwWUhEcVBBMUF2aDlPeERURjZnbE1mdU9JSDE5alNuRllpRzJXbjVoN09HSkZHS3NMV05PSVVkT0VOeVNUWjNJYjg3VmRiLytORUJEbkMyVDN4d0htVEdhOHpZTWw0SmZMNHhJQjd5emc4c1dmR0NZZDhfX2V1Yy55b255b3VjbG91ZC5jb20.__6927bb851c3afe3c9ded02a9c71443ea_1647050746568",
    "appSource": "developplatform",
    "category": "developplatform.05534be1",
    "ts": 1647058453850
}
  • businessKey通过_分成了两部分:后面是单据id
  • 例如:05534be1_2684626243162368 ; 2684626243162368 即为单据id,我们可以通过单据id查询到单据信息

let AbstractWorkflowAPIHandler = require('AbstractWorkflowAPIHandler')
  class WorkflowAPIHandler extends AbstractWorkflowAPIHandler {
    // 流程实例初始化
    processInstanceStart(processStartMessage){
      let businessIdArr = processStartMessage.businessKey.split("_");
      let businessId = businessIdArr[1];
      //可以对返回参数进行处理,例如调用第三方接口
      //此处为方便验证调用插入接口
      let sql = "select new2,new3,new4,new5,fujian from GT81114AT94.GT81114AT94.billtest20220310 where id = '"+businessId+"'"
      let res = ObjectStore.queryByYonQL(sql);
      var object = {liuchengshilichushihua:JSON.stringify(res)};
      ObjectStore.insert("GT81114AT94.GT81114AT94.approvesql",object,"08233b8a");
    }

    // 流程完成
    processInstanceEnd(processStateChangeMessage){
      let businessIdArr = processStateChangeMessage.businessKey.split("_");
      let businessId = businessIdArr[1];
      //可以对返回参数进行处理,例如调用第三方接口
      //此处为方便验证调用插入接口
      let sql = "select new2,new3,new4,new5,fujian from GT81114AT94.GT81114AT94.billtest20220310 where id = '"+businessId+"'"
      let res = ObjectStore.queryByYonQL(sql);
      var object = {liuchengwancheng:JSON.stringify(res)};
      ObjectStore.insert("GT81114AT94.GT81114AT94.approvesql",object,"08233b8a");
    }

    // 环节结束
    activityComplete(activityEndMessage) {

    }
  }
  exports({"entryPoint":WorkflowAPIHandler});

三、效果

四、说明

审批流脚本中可以获取到对应的单据信息,可以将信息传给第三方。 如果有上传附件需求,字段对应的fujian值就是协同【附件上传】的businessId

Copyright © 用友 -【生态技术部】 2021 all right reserved,powered by Gitbook修订时间: 2022-03-12 14:27:51

results matching ""

    No results matching ""