Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications

|

Creating Unique Behavior on Role-Based Forms in Dynamics CRM 2011

Post Author: Joe D365 |

There are a lot of benefits to working with role-based forms in Dynamics CRM, as listed in our blog on pros and cons of role-based forms. But one challenge comes when teams using role-based forms need to see different behavior with the fields on each form. For example, one team needs to see Section A, and another team needs to see Section B. In this case, the solution is to include the form name in the JavaScript so that it may operate differently on different forms.

In order to use the form name in Microsoft Dynamics CRM 2011, you use this element as a base.

    var item = Xrm.Page.ui.formSelector.getCurrentItem();
    if (item.getLabel() == "[Specific Form Name]")
            // Your desired changes

From there, you can customize your form on demand as needed, such as setting different fields to be required or pre-populating some information so that users don't have to.

    Xrm.Page.getAttribute("[field]").setRequiredLevel("required");
    Xrm.Page.getAttribute("[field]").setRequiredLevel("none");            
    [field].setValue([value]);

Now, if you want to change the functions of the ribbon instead, you can combine this with Tooltips for Disabled Ribbon Buttons in CRM 2011 and have even more ability for customization and adding your own buttons to each form.

An alternative to using the form name would be to have JavaScript check the user's security role as describe in this article on Useful JavaScript for Microsoft Dynamics CRM. However, using the form name in the JavaScript should fulfill most requirements.

Happy CRM'ing!

Joe CRM
By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

PowerObjects Recommends