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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Select tab based on active stage

(0) ShareShare
ReportReport
Posted on by 27
Hi everyone,
 
Could anyone share sample js script for directing the user to a specific tab in a Form, based on the active stage in a business process flow?
 
Best regards,
Imran Khan
  • Suggested answer
    Haig Liu Profile Picture
    Microsoft Employee on at
    Hi ImranAmi,
     
    Using the Dynamic 365 Sales opportunity table as an example, the pipeline phase field on the opportunity table records the BPF stage.
    So when the pipeline phase field changes we can apply the JS code in the link to focus the tab:
     
    Best Regards,
    Haig Liu
  • Ami K Profile Picture
    27 on at
    I am aware of using of set focus to move to a specific tab, my question was whether had anyone any js script to move to a specific tab when the active stage has changed.
     
    Best regards,
    Imran Khan
  • Suggested answer
    Ami K Profile Picture
    27 on at
    One solution:
     
    ​
    function onLoad(executionContext) {
        var formContext = executionContext.getFormContext();
        formContext.data.process.addOnStageChange(onStageChange)
    }
    
    function onStageChange(executionContext) {
        var formContext = executionContext.getFormContext();
        var stage = formContext.data.process.getSelectedStage();
        var stageName = stage.getName();
    
        if (stageName == "Draft") {
            formContext.ui.tabs.get("tab_one").setFocus();
        } else if (stageName == "Submitted For Approval") {
            formContext.ui.tabs.get("tab_two").setFocus();
        } else if (stageName == "Approved") {
            formContext.ui.tabs.get("tab_three").setFocus();
        }
    }
    
    
     

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 Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
11manish Profile Picture

11manish 46 Super User 2026 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 37 Super User 2026 Season 2

#3
Travis South Profile Picture

Travis South 35

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans