web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Release Wave Forum
Suggested Answer

How to get Stage ID in Dynamics 365 Web Resource?

(0) ShareShare
ReportReport
Posted on by 52

I'm migrating from CRM 2015 to Dynamics 365 and there is a web resource that has code breaking which is:

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.

I have the same question (0)
  • Suggested answer
    Summers Profile Picture
    52 on at

    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:

    pastedimage1670343532649v1.png

  • Walpha Profile Picture
    10 on at

    To get the Stage ID in a Dynamics 365 Web Resource, you can use the Xrm.Page.data.process API. This API provides methods and properties for working with business processes and the stages within those processes. To get the Stage ID, you can use the getActiveStage method, which returns an object that contains information about the current stage, including the Stage ID. Here is an example of how to use this method:

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

    Once you have the Stage ID, you can use it to perform operations on the stage, such as moving to the next stage in the process or completing the stage.

  • Summers Profile Picture
    52 on at

    Please see my answer, the syntax I provided is the replacement for the deprecated “Xrm.page…” way, thanks.

  • HS-30042052-0 Profile Picture
    10 on at
    Use my following code get the Stage ID in a Dynamics 365 Web Resource in Dynamics 365
     
    var stageObject = executionObj.getFormContext().data.process.getActiveStage();
    var stageId = stageObject?.getId();
     
    You must check if the stageObject is not null before trying to get its ID, otherwise you will get a script error.
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans