首页 > 解决方案 > JS 中的 getDirection() 确定 Dynamics 365 中 BPF 中的方向

问题描述

我在机会实体的保存上编写了以下代码:

function bpf(executionContext)
{
    var formContext = executionContext.getFormContext();
    formContext.data.process.addOnStageChange(function () {
      //  debugger;
        //alert("JS called");
        var stageName = formContext.data.process.getSelectedStage().getName().toString().toLowerCase();
        //alert(stageName);
        var accountApproved = formContext.getAttribute("new_accountstatusapproved");
        var direction = executionContext.getEventArgs().getDirection();

        //alert(direction);

        if (stageName != "" && stageName === "check status" && accountApproved != null && accountApproved.getValue() != null && accountApproved.getValue() == 0)
        {
            //debugger;
            formContext.data.process.movePrevious();
            formContext.ui.setFormNotification("The Account is not Approved.", "WARNING", "1");
        }

    });
}

基本上,我需要使用以下行获取 BPF 的方向:

var direction = executionContext.getEventArgs().getDirection();

getDirection() 没有按预期工作。该控件将转到ribbon.js 中的其他一些功能,并且需要无限的时间。

我在这里错过了什么?

谢谢

标签: javascriptmicrosoft-dynamicsdynamics-365

解决方案


executionContext 是对保存事件的引用。您修改 addOnStageChange 回调函数以接收舞台上下文

function bpf(executionContext)
{
    var formContext = executionContext.getFormContext();
    formContext.data.process.addOnStageChange(function (stageContext) {

        var direction = stageContext.getEventArgs().getDirection();

        ...
    });
}

推荐阅读