How to get Stage ID in Dynamics 365 Web Resource?

1.1k Views Asked by At

I have a form in which I pass the execution context as the first parameter to the web resource:

onpage load parameter

I'm migrating from CRM 2015 to Dynamics 365 and there is a line of code in the web resource that breaks:

var stageID = Xrm.Page.data.process.getActiveStage().getId();

I'm trying something like this to update the code, but the following still doesn't work:

var formContext = executionObj.getFormContext();

var stageObject = formContext.data.process.getActiveStage();

The stage object is always null, so of course I can't try to get its ID.

Note: Other deprecated JS works.

1

There are 1 best solutions below

0
On BEST ANSWER

It was discovered after all the JS was fixed by first checking the stage object (from formContext.data.process.getActiveStage()) is not null, b/c if you try to getID() with a null stage object Dynamics will throw a script error.

After the fix was applied, the form finally would load correctly but still the BPF wasn't showing on top.

The BPF showed correctly on the form by configuring in general settings this option: legacy form rendering