Saturday, August 14, 2010

Save the last viewed tab

I've had alot of clients to ask me about this. Keep in mind that this is really for CRM 4.0.
The scenario goes that you may be asked to perform some save events that happens on a form. The form has a couple of tabs, and the save event happens on the 3rd tab. The form reloads back on the first tab. It gets pretty annoying especially when you have alot of tabs (not saying some CRM dev might have hacked the number of tabs on a form).





function OnCrmPageLoad()
{
if( crmForm.FormType == 2)
RetainTab();
}

function RetainTab()
{
crmForm.attachEvent( "onsave" , OnCrmPageSave );
var regTab = new RegExp( window.name + "=(\\d)","gi");
regTab.exec(document.cookie);
var tab = document.getElementById("tab"+RegExp.$1+"Tab");
if( tab ) tab.click();
}

function OnCrmPageSave()
{
var crmTabBar = document.all.crmTabBar;
for(var i = 0 ; i < cookie =" window.name+"="+i;
break;
}
}
}

OnCrmPageLoad();

No comments:

Post a Comment