I have some JavaScript that shows/hides tabs on a record based on information on the form. The code starts by hiding all the special tabs and then shows the appropriate special tabs based on the person's major. I've included the code below...
Now, it works just fine for everything except Music. With Music it shows Music no matter what. Now I can hide music by commenting out the three lines that say to set visible if the major equals xyz, but if I uncomment it, then it shows Music no matter what. Why?!? Help!
Thanks,
Dave
function ApplicationExtrasRefresh() { var tabs = Xrm.Page.ui.tabs.get(); var major = Xrm.Page.getAttribute("new_major").getText(); if (major !== null) { major = major.slice(0,3) } for (var i in tabs) { var tab = tabs[i]; if (tab.getLabel() == 'Music') { tab.setVisible(false); } if (tab.getLabel() == 'Degree Completion') { tab.setVisible(false); } if (tab.getLabel() == 'M.S. in Education') { tab.setVisible(false); } if (tab.getLabel() == 'M.S. in Educational Leadership and Administration') { tab.setVisible(false); } if (tab.getLabel() == 'M.B.A.') { tab.setVisible(false); } if (tab.getLabel() == 'M.S. in Organizational Leadership') { tab.setVisible(false); } if (tab.getLabel() == 'M.Div.') { tab.setVisible(false); } if (tab.getLabel() == 'M.S. in Bible') { tab.setVisible(false); } if (tab.getLabel() == 'M.S. in Christian Counseling') { tab.setVisible(false); } if (tab.getLabel() == 'Counseling 3rd Year Certificate') { tab.setVisible(false); } } tab = '0'; i = '0'; for (i in tabs) { var tab = tabs[i]; if ((tab.getLabel() == 'Music') && ((major == 'MAM') || (major == 'zMC') || (major == 'MC5')) ) { tab.setVisible(true); } if ((tab.getLabel() == 'Music') && ((major == 'MMD') || (major == 'MPF') || (major='MPE') || (major == 'MME')) ) {tab.setVisible(true); } if ((tab.getLabel() == 'Music') && ((major == 'MCP') || (major=='MCO') || (major =='MCH')) ) { tab.setVisible(true); } if ((tab.getLabel() == 'Degree Completion') && (major == 'ADV')) { tab.setVisible(true); } if ((tab.getLabel() == 'M.S. in Education') && (major == 'GED')) { tab.setVisible(true); } if ((tab.getLabel() == 'M.S. in Educational Leadership and Administration') && (major == 'GEL')) { tab.setVisible(true); } if ((tab.getLabel() == 'M.B.A.') && (major == 'GBA')) { tab.setVisible(true); } if ((tab.getLabel() == 'M.S. in Organizational Leadership') && ((major == 'GOC') || (major == 'GOL')) ) { tab.setVisible(true); } if ((tab.getLabel() == 'M.Div.') && (major == 'GDV')) { tab.setVisible(true); } if ((tab.getLabel() == 'M.S. in Bible') && (major == 'GBS')) { tab.setVisible(true); } if ((tab.getLabel() == 'M.S. in Christian Counseling') && (major == 'GCC')) { tab.setVisible(true); } if ((tab.getLabel() == 'Counseling 3rd Year Certificate') && (major == 'GCC')) { tab.setVisible(true); } } }