Lets be honest: nobody need role-based forms! Most of customers want to have condition-based forms instead of role-based. The reason is simple: same people are used to work with different kind of data stored in the same entity. For example, call center operators or front-office workers used to work with different types of customers (natural persons, legal entity, corporate customers, etc.) and/or with wide range of case types.
It’s allays a good idea to avoid dealing with heavily customized entities but unfortunately it’s a common practice for industries such as telecommunication or banking. Different types of Customers/Accounts or Cases can really have more more differences than similarities. But… this is still a customer who need to be serviced and still a case that require resolution. And fast! This is a front line after all.
Approaches to deal with this challenges can be different: God-form, custom UI, switching form using script, or even using some unsupported ways. But what if I tell you that there is a simple supported way to override the default form open behavior? This small but very powerful feature was missed from documentation for some reason, but is still available in “what’ new”: https://docs.microsoft.com/en-us/dynamics365/get-started/whats-new/customer-engagement/new-in-version-9-for-developers#override-the-default-open-behavior-of-data-rows-in-an-entity-bound-grid.
The idea here is to create/override new Ribbon command named
Mscrm.OpenRecordItem. Then this command will be executed instead of opening the entity record. This phenomenon requires further research, but this seems to be ordinary grid command so we should be available to get
SelectedControlSelectedItemIds parameter to find out entity id. Then we can use
Xrm.Navigation.openFormto open specific form.
Doc suppose this feature to be used to open non native URLs such as SharePoint site, but the truth here is that we can use it to finally fix OOB forms to make them condition-based. Off cause this is not silver bullet! There is still a lot of challenges when you deal with multiple forms, but now you have one more option.
Use it carefully and don’t forget to properly document such things in your TDD’s! 🙂