New in Microsoft Dynamics CRM 2011 is the possibility to create multiple forms for the same entity. This makes the following scenario's possible:
In this post I will show:
At the bottom, I will also give some 'best practices' to allow you to pick the right multiple form strategy.
How to change forms with javascript will be the topic of a different post where I will also look into 'dialog style' forms.
Suppose we are designing a system for a Real Estate Agency. Their agents can be employed in two roles: as a Buying Agent or as a Listing Agent. Potential sales for either role will be tracked using opportunities so a nice pipeline can be created giving an overview of all potential revenue.
As a Buying Agent they need to track information about the desires (and constraints) of the buyer. So let us create a form for that. Go to the list of opportunities, change the ribbon to the Customize tab and choose 'Customize Entity'.
The new customization center will show in a different window. The opportunity entity will already be selected. Choose 'Forms' in the left menu and select New -> Main form:
The form designer will open with a new 'almost blank' form. Use the 'Form Properties' button on the 'Home' tab in the ribbon to set the name of the form.
After adding a few fields, select Save and then Publish.
This form will now be the default (for 'System Administrator' and 'System Customizer', more on that later) but in order for this default to be effective, you need to close all instances of Internet Explorer and then return to CRM. Opening an opportunity with the sample data now looks like:
A bonus of this new 'multiple forms' feature is that it is also a way to customize printing behavior. When printing a record, the layout of the current form is used for printing:
Tip: when creating specialized forms as in this example, leave the default form for what it is. This keeps the default form available for all people not requiring a specialized form. Also, the default form is always present so other customizations might depend on it, especially if these customizations originate from older versions of CRM where multiple forms do not exist.
Go to the Customize tab on the ribbon and choose Design, Form to open the Form Editor.
Choose Assign Security Roles:
Under 'Assign Security Roles' you can select the roles that you want to have access to this form (or use the radio button to give all roles access). There is also a 'Enabled for fallback' option (selected below, by default unselected).
This works as follows:
This means that as soon as you explicitly assign a form to a role, the default form is no longer shown. If you want to continue to have the default form available to that role, you need to explicitly assign the default form as well.
The default 'Information' form is assigned to no roles and has 'enabled for fallback' selected. New forms are by default assigned to 'System Administrator' and 'System Customizer'. This means that for 'us customizers' a newly published form will replace the default form as we now have a form assigned explicitly, but for all other users the new form remains invisible. This is nice default behavior as it will enable us to test the new situation for the role we intend to target for the form.
For this example we will give the 'System Adminstrator' role two forms to choose from. This can be accomplished by checking the assignment box for the 'System Administrator' role on the default 'Information' form. This gives the administrator two explicitly assigned forms.
Alternatively, we could clear the assignment checkbox for 'System Administrator' on the 'Buyer' form and checking fallback. This gives all roles two fallback forms and because the 'System Administrator' role now has no forms assigned, it will use both fallback forms.
Now we have both the default form (titled 'Information') and the new form ('Buyer') available. The desired form can be selected in the navigation pane, left:
The form that opens by default for a record is the first form in the 'assignment order'. This assignment order can be modified as follows. Go to the customization center for the Opportunity entity again (see above or via Settings -> Customization; Components -> Entities -> Opportunity) and select Forms, we can change the 'Form Order':
A dialog opens where we can change the order:
Determining the default form for a user works as follows:
This means that getting the default form right for all users can be a bit tricky if forms are re-used between roles in different combinations and users are assigned to multiple roles. In practice, however, this is seldom the case.