Wednesday, August 13, 2008

Handling CRM Tabs

The first piece of code is a helper function which enables you to reference a tab by name.

The second one re-aranges the tab order from a top - down to a left - right order which makes more sence to most users.


function OnCrmPageLoad()
{
var tab = GetTab( "Notes" );
}

/* Get tab by name */
function GetTab( name )
{
var tabs = crmTabBar.getElementsByTagName("LI");
for( var i = 0 ; i < tabs.length ; i++ )
{
if( tabs[ i ].innerText == name )
return tabs[ i ];
}
return null;
}

OnCrmPageLoad();



function OnCrmPageLoad()
{
ReArangeTabIndex();
}

function ReArangeTabIndex()
{
for( var i = 0 ; i < crmForm.all.length ; i++ )
if( crmForm.all[ i ].tabIndex )
crmForm.all[ i ].tabIndex = 1000 + (i*10);
}
}

OnCrmPageLoad();

1 comment:

Anonymous said...

I'm trying to get the second code sample to work on one of my CRM forms, however whenever the tab reaches a lookup field it becomes "stuck" and won't move on to the next field unless you manually reposition the cursor.