Fix: Business Proces Flow not updating stepname

In january 2019, I started getting reports from customers, that their business process flows was not updating the stepname on opportunity records anymore. Logs showed, the fields were updated in december 2018, but suddenly stopped working.

Ofcause I started to look into this, and what I found was, that the fields that were being updated, was actually deprecated in Dynamics 365. Somehow the fields were still being updated – but that’s a different story. The issue at hand is, the fields are not being filled out/updated – what to do?

From my personal testing (creating a new entity on a clean environment with BPF), I am unable to find any way to fetch the stagename from the active stage using standard CRM functionality.

Looking into the matter, I found this forum post: https://community.dynamics.com/crm/f/117/t/267468

This post described how to get the data with javaScript. I would prefer, if it was easily available inside standard CRM, but I tried the code out:

// This function fetches the active stage on load, and sets the name of the active stage to a custom specified field
function formonload() {
Xrm.Page.data.process.addOnStageChange(getStage); // Trigger the function when move to next stage.
getStage();
}
// this getStage function is triggered by the formonload function, which fetches the name of the active BPF
function getStage() {
var activeStage = Xrm.Page.data.process.getActiveStage(); // Retrieve the active stage
var stageId = activeStage.getId();
var stagename = activeStage.getName(); // Retrieve the name of the active stage
Xrm.Page.getAttribute("ct_js_stagename").setValue(stagename); // set the name into the specified field
}

This piece of code worked like a charm, and the specified field is updated on stage change.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *