[英]How can I tell if user is moving to next or previous stage of business process flow when OnStageChange event is fired in Dynamic 365 Online?
I'm writing a JS script to intercept and do some additional validations when user moved to the next stage of business process flow in Dynamic 365 Online. 当用户移至Dynamic 365 Online中的业务流程的下一阶段时,我正在编写一个JS脚本以进行拦截并进行一些其他验证。
I'm binding my function to OnStageChange event of Dynamic 365, but that event is not only fired when a user moved to next stage but also when he moved back to previous stage as well. 我将函数绑定到Dynamic 365的OnStageChange事件,但是该事件不仅会在用户移至下一个阶段时触发,而且还会在用户移回到上一个阶段时触发。
Is the any way to tell if the user is moving to the next or the previous stage? 有什么办法可以告诉用户是进入下一个阶段还是上一个阶段?
You'll need to update your code for the OnStageChange
to getEventArgs
, this will allow you to see if the getDirection
was 'next' or 'previous.' 您需要将
OnStageChange
的代码更新为getEventArgs
,这将使您查看getDirection
是“下一个”还是“上一个”。
Without seeing your code, I can't provide specific implementation advice, but this answers your question. 没有看到您的代码,我无法提供具体的实施建议,但这可以回答您的问题。
Below is the link for further understanding how to handle `OnStageChange' events: 以下是用于进一步了解如何处理“ OnStageChange”事件的链接:
https://msdn.microsoft.com/en-us/library/gg334481.aspx#BKMK_OnStageChange https://msdn.microsoft.com/en-us/library/gg334481.aspx#BKMK_OnStageChange
Thanks to @OneNeptune, I managed to solved my problem as follow. 感谢@OneNeptune,我设法解决了以下问题。
const NEXT_STAGE_OPTION = "Next"
function onAccountFormLoad (context) {
context.getFormContext().data.process.addOnStageChange(checkMoveStage);
}
function checkMoveStage(context) {
var targetStageName = context.getFormContext().data.process.getActiveStage().getName();
var direction = context.getEventArgs().getDirection();
console.log("Move to " + direction + " stage:" + targetStageName);
if (direction === NEXT_STAGE_OPTION) {
// Perform necessary validation when moving to next stage.
}
}
Function onFormLoad is added to onLoad event of form, with "Pass execution context as first parameter" option checked. 函数onFormLoad被添加到窗体的onLoad事件中,并且选中了“将执行上下文作为第一个参数”选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.