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)

Expand/Collapse Tab based on stage of Business process flow

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Verified answer
    Shaminderpal Singh Profile Picture
    1,565 on at

    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

  • Community Member Profile Picture
    on at

    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

  • Community Member Profile Picture
    on at

    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
    on at

    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");		
    
    }


  • Verified answer
    Shaminderpal Singh Profile Picture
    1,565 on at

    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
    on at

    Hi Shaminder,

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

    Best,

    Jon

  • Shaminderpal Singh Profile Picture
    1,565 on at

    Thanks Jon!

    Glad to know it solved your issue.

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