[Quick Tip] Get SubGrid View Id using Primary Control or Selected Control for Ribbon button’s enable rule in Dynamics 365 CRM.
Use case: I have two entity Awards and Awards category. We have SubGrid on the Awards entity form for Category with Custom Ribbon button. We want to have the button should be visible on specific view only and below are steps to do so.
Step 1: Configure the Ribbon Button
Step 2: Get View id based on the CRM parameter:
Now, Get Subgrid view id by passing the CRM parameter in the custom rule.
When CRM parameter is Primary Control
When CRM parameter is Selected Control
Step 3: Write script for Enable Rule for Custom Ribbon Button.
We will write a script that will enable or disable the Ribbon based on the view ID using the above code based on the passed parameter.
I have written the enable rule that Button should be visible only on the Active Award Category view: