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 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
I have the same question (0)
  • 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

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 | Integration, Dataverse, and general topics

#1
#ManoVerse Profile Picture

#ManoVerse 93

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 62 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans