CRM is setting focus to a field in your first tab after you collapse them all, which is automatically expanding the tab again.
You can get around this by setting a timeout before collapsing the first tab, something like this (increase the timeout if it's not long enough):
// ONLOAD - COLLAPSE ALL TABS
function collapse() {
var formtabs = Xrm.Page.ui.tabs.get();<o:p></o:p>
for(var i in formtabs) {
var tab = formtabs[i];
var currentTabState = tab.getDisplayState();
var newTabState = "";
if (currentTabState == "expanded") {
newTabState = "collapsed";
}
tab.setDisplayState(newTabState);
}
setTimeout(function() {
formtabs[0].setDisplayState("collapsed");
}, 100);
}
Hope that helps
Paul
If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".
