BPF(Business Process Flow)相关的JS
为Stage添加changed或者selected事件:
function fnOnLoad() {
Xrm.Page.data.process.addOnStageChange(fnStageChanged); //change事件
Xrm.Page.data.process.addOnStageSelected(fnStageSelected); //select事件
}
function fnStageChanged(execContext){
var currentStage = execContext.getEventArgs().getStage(); //获取当前Stage
.....
}
获取当前Stage:
var activeStage = Xrm.Page.data.process.getActiveStage();
获取当前Stage的名称:
var sName = activeStage.getName();
更多相关的api可以参考:https://adisys.wordpress.com/2017/01/03/dynamics-crm-scripting-for-business-process-flows/
Stage下的字段名(step):
"header_process_sFiledName",可用F12查看,若存在同名step,系统会自动在后面累加数字,比如:"header_process_sFiledName_1"
Stage下的字段加锁(设置只读):
Xrm.Page.getControl("header_process_sFiledName_1").setDisabled(true);
设置BPF的状态:
Xrm.Page.data.process.setStatus("finished"); //set finished,BPF流程已经完成
获取BPF的状态:
var oStatus = Xrm.Page.data.process.getStatus();
oStatus == "active"; //BPF处于active状态,未finished
oStatus == "finished"; //BPF处于finished状态
oStatus == "aborted"; //BPF处于abandon状态,灰色不可编辑
abandon一个BPF:
Xrm.Page.data.process.abandonProcess();
reactivate一个BPF:
Xrm.Page.data.process.reactivateProcess();
原文地址:https://www.cnblogs.com/Sunny20181123/p/10272414.html