Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Expand/Collapse Tab based on stage of Business process flow

Posted on by Microsoft Employee

Hi experts,

I have 3 stages in my BPF identify, research, and resolve. I would like to expand and collapse the tabs labelled General, Case Relationships, and Associated Knowledge Records. 

Screen-Shot-2018_2D00_05_2D00_01-at-1.36.12-PM.png

I would like collapse the General tab when the research stage is active and collapse the Case Relationships tab when the resolve stage is active. 

I am using the following code to test the requirement, but its not working:

function HideShow()
{
	var stage = Xrm.Page.data.process.getActiveStage().getName();
	if (stage == "identify")
		Xrm.Page.ui.tabs.get("CASERELATIONSHIP_TAB").setDisplayState('expanded');
	else if (stage == "research")
		Xrm.Page.ui.tabs.get("CASERELATIONSHIP_TAB").setDisplayState('collapsed');		
}

Please suggest changes that I can make to the code.


Thanks,

Jon

*This post is locked for comments

  • Shaminderpal Singh Profile Picture
    Shaminderpal Singh 1,565 on at
    RE: Expand/Collapse Tab based on stage of Business process flow

    Thanks Jon!

    Glad to know it solved your issue.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Expand/Collapse Tab based on stage of Business process flow

    Hi Shaminder,

    IT WORKS!! Thank you so much!!! You're a really strong coder!

    Best,

    Jon

  • Verified answer
    Shaminderpal Singh Profile Picture
    Shaminderpal Singh 1,565 on at
    RE: Expand/Collapse Tab based on stage of Business process flow

    Hi Jon,

    I have modified your code.Please try to run the below

    function HideShow()

    {

    var stage = Xrm.Page.data.process.getActiveStage().getName();

    alert(stage);

    if (stage === "Identify")

    Xrm.Page.ui.tabs.get("CASERELATIONSHIP_TAB").setDisplayState("collapsed");

    else if (stage === "Research")

    Xrm.Page.ui.tabs.get("CASERELATIONSHIP_TAB").setDisplayState("collapsed");

    Xrm.Page.data.process.addOnStageChange(function(e){

    var stage= e.getEventArgs().getStage().getName();

    if (stage === "Identify")

    Xrm.Page.ui.tabs.get("CASERELATIONSHIP_TAB").setDisplayState("collapsed");

    else if (stage === "Research")

    Xrm.Page.ui.tabs.get("CASERELATIONSHIP_TAB").setDisplayState("collapsed");

    });

    }

    -Shaminder

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Expand/Collapse Tab based on stage of Business process flow

    This is the code I am using onLoad() of form. I would like for it to change every time the user changes the BPF stage. 

    function HideShow()
    {
    var stage = Xrm.Page.data.process.getActiveStage().getName();
    alert(stage);
    	if (stage === "Identify")
    		Xrm.Page.ui.tabs.get("CASERELATIONSHIP_TAB").setDisplayState("collapsed");
    	else if (stage === "Research")
    		Xrm.Page.ui.tabs.get("CASERELATIONSHIP_TAB").setDisplayState("collapsed");		
    
    }


  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Expand/Collapse Tab based on stage of Business process flow

    Hi Shaminder,

    Just another update: I got my code to work now. It was in fact a uppercase lowercase problem.

    However, I still want the tab to also expand/collapse when the user changes (onChange) stages of the BPF on the form. How can I accomplish this?

    Thanks,

    Jon

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Expand/Collapse Tab based on stage of Business process flow

    Hi Shaminder,

    Thank you for your reply once again.

    I made the change as you suggested but its not working.

    Also this script is set on load of the form, so when the page loads it will see the active stage and expand/collapse tabs accordingly.

    However, I want the tab to also expand/collapse when the user changes (onChange) stages of the BPF on the form.

    Thanks,

    Jon

  • Verified answer
    Shaminderpal Singh Profile Picture
    Shaminderpal Singh 1,565 on at
    RE: Expand/Collapse Tab based on stage of Business process flow

    Hi Jon,

    Your code is right,just makes sure while comparing take care of lowecase and uppercase

    make the change like below  for every if condition to

    if ( String(stage).toLowerCase() === "identify")

    -Shaminder

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans