简体   繁体   English

当在Dynamic 365 Online中触发OnStageChange事件时,如何确定用户是转到业务流程的下一阶段还是上一步?

[英]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.

相关问题 使用 Business Process Flow Next Stage 按钮触发电源自动化流程 - Trigger power automate flow with Business Process Flow Next Stage button 限制用户手动选择业务流程阶段 - Restrict user to select business process flow stage manually 如何确定某个事件是否由创建该事件的同一事件触发? - How can I tell if an event is being fired by the same event that created it? 如何判断.click()或用户是否触发了某个事件? - how do I tell if an event is fired by .click() or by the user? Dynamics 365 WebAPI 获取业务流程阶段 - Dynamics 365 WebAPI getting Business Process Flow stages 当离线或在线连接到互联网时,如何更改我的图片, - How can i change my image when connection to internet is fired offline or online, 如何判断刚刚触发的Javascript事件 - How to tell what Javascript event just fired 获得Microsoft 365订阅价格时应使用的api(即Office 365 Business Essentials-$ 6 /每用户每月) - What api to use when getting Microsoft 365 subscription price (i.e Office 365 Business Essentials - $6 / per user per month) 通过javascript在汇总1后损坏的业务流程动态更新 - Business process flow dynamic update via javascript broken after rollup 1 我想在启动mouseup时停止mousemove事件,但似乎不起作用,该怎么办? - I want to stop the mousemove event when mouseup is fired.But it seems not working.How can i do that?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM