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