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 :
Microsoft Dynamics CRM (Archived)

Trigger to set next business process stage active

(0) ShareShare
ReportReport
Posted on by

How can I trigger to set next stage of a business process, active, based on a no/yes field filled out?

Thanks!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Barry,

    You can simply call a javascript function on change of two option field. In the javascript function you need to write following.

    If option value is yes then save the data first and then move to next stage.

    Xrm.Page.data.entity.save();

    Xrm.Page.data.process.setActiveStage(stageId, callbackFunction);

    You need to provide stage I'd which you want to redirect .

    Hope this helps.

  • Community Member Profile Picture
    on at

    Thanks Goutam!

    I am going to try your suggestion I'm just wondering how do I know the stageId for the stage I want to set active?

  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at

    Hi Barry,

    You can get the StageId using this JavaScript.

    function onLoad() {
    Xrm.Page.data.process.addOnStageChange(getStage);
    getStage();
    }

    function getStage() {
    var activeStage = Xrm.Page.data.process.getActiveStage();
    var stageId = activeStage.getId();
    var stageName = activeStage.getName();
    }

    The old StageId JavaScript is deprecated in Dynamics 365, as it can no longer reliably be used to determine which process is running on a record or as triggers to workflows or other automated tracking. More information on this can be found here.

  • Community Member Profile Picture
    on at

    Thanks Adrian! I'm gong to try your suggestion...

    Is there a way to get a stageId by stage name?

  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at

    Hi Barry,

    I am not sure what you would need that for, as you can get both the Stage Id and the Stage Name from a stage using JavaScript.

    You may find the other JavaScript methods for Business Process Flows found on this link to be useful.

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans