I have a Case design that has multiple tabs. The tabs relate to the the value given in the Subject. I want the script to be able to hide all the tabs, and only display the tab that relates to the Subject value (I have created a Business Rule that maps the Subject value to the Description field).
The code below works OK but does not hide all the tabs when the form is loaded, then displays only the Subject 1 tab. It displays all the tabs once the form has loaded, then hides the specified tabs once the Subject has been set, leaving only the Subject 1 tab on display. It would work better if all tabs were hidden On Load, then only displayed the required tab once the Subject value has been set.
Could anyone who is skilled in jscript suggest a solution?
//Description: description
//To show/hide tab:
//Xrm.Page.ui.tabs.get("tab_system_name").setVisible(true/false);
function showHideTab() {
var Description = Xrm.Page.getAttribute("description").getValue() //Description: the trigger value
var showTab = true;
if (Description == "Subject 1") {
showTab = false;
}
Xrm.Page.ui.tabs.get("Subject 2_Details_Tab").setVisible(showTab);
Xrm.Page.ui.tabs.get("Subject 3_Details_Tab").setVisible(showTab);
Xrm.Page.ui.tabs.get("Subject 4_Details_Tab").setVisible(showTab);
}
Hello Leah Ju
Yes, that is correct, this works for one scenario only. I want to get the script that checks the rest of the scenarios, the If then Else part.
The code below hides the unrequired tabs and then displays the required tab, based on the Subject value. I require the script that works when the Subject value changes.
//Description: description
//To show/hide tab:
//Xrm.Page.ui.tabs.get("tab_system_name").setVisible(true/false);
function showHideTabs() {
var Description = Xrm.Page.getAttribute("description").getValue() //Description: the trigger value
if (Description == "Subject 1") {
}
Xrm.Page.ui.tabs.get("Subject 1_Details_Tab").setVisible(true);
Xrm.Page.ui.tabs.get("Subject 2_Details_Tab").setVisible(false);
Xrm.Page.ui.tabs.get("Subject 3_Details_Tab").setVisible(false);
Xrm.Page.ui.tabs.get("Subject 4_Details_Tab").setVisible(false);
}
Chris
Hi Partner,
As you mentioned, "The code below works OK but not hide all the tabs when the form is loaded".
Uncheck 'Visible by default' option can hide the tab when the form is loaded, then the js you added can work based on subject value to show tab you want.
Regards,
Leah Ju
Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.
Hello Leah Ju
Many thanks for your response. This doesn't seem to do what I was wanting. I want the control of the tab visibility to be based upon the value in the Subject field.
So,
If Subject = "Subject 1", then hide tabs Subject 2, Subject 3, Subject 4. Only display tab Subject 1.
Else, if Subject = "Subject 2", then hide tabs Subject 1, Subject 3, Subject 4. Only display tab Subject 2.
...and so on.
I am looking for the script to control the visibility of the tabs, based upon the Subject value, using an If then Else scenario.
Chris
Hi ChrisCroft,
You can go Settings > Customizations > Customize the System > Entities > select one entity > Forms > open one form you need.
Double-Click tab that you want to hide to open 'Tab Properties' dialog, and uncheck 'Visible by default' option.
For 'Related' tab, which is special, you need open 'form properties'and click on Display tab to uncheck the checkbox 'Show Navigation Items'.
Result:
Before:
After:
Regards,
Leah Ju
Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,900 Super User 2024 Season 2
Martin Dráb 229,297 Most Valuable Professional
nmaenpaa 101,156