title: getDirection() in JS to determine the direction in BPF in Dynamics 365
body: <p>I have written the following code onSave of Opportunity Entity: </p>
  
  <pre><code>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 != "" &amp;&amp; stageName === "check status" &amp;&amp; accountApproved != null &amp;&amp; accountApproved.getValue() != null &amp;&amp; accountApproved.getValue() == 0)
          {
              //debugger;
              formContext.data.process.movePrevious();
              formContext.ui.setFormNotification("The Account is not Approved.", "WARNING", "1");
          }
  
      });
  }
  </code></pre>
  
  <p>Basically, I need to get the direction of the BPF using the following line : </p>
  
  <pre><code>var direction = executionContext.getEventArgs().getDirection();
  </code></pre>
  
  <p>getDirection() is not working as expected. The control is going to some other function in ribbon.js and is taking infinite amount of time.</p>
  
  <p>What have I missed here? </p>
  
  <p>Thanks</p>