CRM 2011 introduced the feature to design more than one form for an entity and assign form to users based on their role (Role Based Form). It has also included a feature where by it would automatically open the form that was last used by the logged in user for that entity. If you would like the entity to dynamically load a particular form you can use the following piece of code
Xrm.Page.ui.formSelector.items.get(formId).navigate( );
Formid – Guid of the form that you would like to navigate to.
You can add this code on the Load event of the form. But make sure you compare the Current form unique id with the id of the form you wish to navigate to. Failure to do this would result in an infinite loop of form navigation.
Var CurrentFormId = Xrm.Page.ui.formSelector.getCurrentItem( ).getId( );
if( formId!=” && CurrentFormId !=” && formId!=CurrentFormId )
{
Xrm.Page.ui.formSelector.items.get(formId).navigate( );
}
While at this, you can use the following code to get a list of all the forms that the user has access to for the current entity
var items = Xrm.Page.ui.formSelector.items.get( );
for (var i in items)
{
var item = items[i];
// Get the Id of the Form
var itemId = item.getId( );
// Get the Label of the Form
var itemLabel = item.getLabel( );
}
Note: Since this code is written in the Onload event, the form is loaded before the script is executed and the user is navigated to the requested form. It would be a good idea to hide the controls on the form and show them in the Load Event.