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

Announcements

News and Announcements icon
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,032 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,032 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans