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.

  • HS-30042052-0 Profile Picture
    HS-30042052-0 10 on at
    How to get Stage ID in Dynamics 365 Web Resource?
    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.
     
  • Summers Profile Picture
    Summers 52 on at
    RE: How to get Stage ID in Dynamics 365 Web Resource?

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

  • Walpha Profile Picture
    Walpha 10 on at
    RE: How to get Stage ID in Dynamics 365 Web Resource?

    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.

  • Suggested answer
    Summers Profile Picture
    Summers 52 on at
    RE: How to get Stage ID in Dynamics 365 Web Resource?

    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

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,309 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans