MS Dynamics CRM :Wanna customize OOB sub grid's button(s) of same entity?? Check this out !!!

MS Dynamics CRM :Wanna customize OOB sub grid's button(s) of same entity?? Check this out !!!

It's really very hard to find a form with no sub grids . Grids in CRM could be customized in many ways by selecting different OOB grid controls .But when it comes to customizing a particular button which gets shipped soon after selecting the sub grid is something which needs to be approached with some sensitive touch .

There will be a situation where in we would need to have two or more sub grids with a small twist to the turn like only one amongst must be have a specific button(s) but not for the rest (just customize the grids but showing / hiding a button based on business), say we may need "+ New Deal Participant" for one grid but not for another just like below.

No alt text provided for this image

How could this be achieved ?

This could be achieved with some simple JS script for implementing the business logic to hide / show the button and XRM Tool Box's Ribbon Workbench to configure the button .

Let me try to walk through the process by steps .

Firstly include the sub grids in the target form . In my case it's Deal participant sub grids in Deal form .

Sub Grid on the Deal Form

Above image depicts the sub grids under a tab in Deal form . And their corresponding properties are as below .

No alt text provided for this image
No alt text provided for this image


So next would be creating a solution with the target entity which the sub grid points to Deal Participants entity in this case .

Make sure that the solution doesn't contains any dependencies , meta data info or any such components so that the solution could be easily imported into the Ribbon Workbench .

The solution should be something like below .

No alt text provided for this image

Now we are good to import the solution in the Ribbon Workbench and play with our customization .

No alt text provided for this image

Here the "Mscrm.SubGrid.dealparticipant.MainTab" is what we are in need for now.

No alt text provided for this image

Select the button which need to be customized and select "Customise Button" on right clicking on it . As soon as it's done , we can see something like the below Mscrm.SubGrid.dealparticipant.AddNewStandard and there would be some default "Display Rules " and "Enable Rules" . We can create one as per our requirement . In our case we need to disable the Add new button based on rule .And the JS would be like

DealParticipantRibbon = (function () {


? ? function showHideAddButton(selectedControl) {


? ? ? ? var isVisible = true;
? ? ? ? var viewId = selectedControl._controlDescriptor.Parameters["ViewId"];
? ? ? ? if (viewId == "{6946A788-B9EF-EB11-94EF-000D3A09E388}") {
? ? ? ? ? ? isVisible = false;
? ? ? ? }
? ? ? ? return isVisible;
? ? }


? ? return {
? ? ? ? showHideAddButton: showHideAddButton
? ? };        
})();        

Here it's important that the crmparameter selected is selectedControl as below and publish the solution

No alt text provided for this image

once published , we can get the expected outcome as below

No alt text provided for this image



Karthik Mohan

Product Team @ CAMS | SAFe? POPM Certified | SaaS | Six Sigma Green Belt | Hewlett Packard

3 年

Good to see such write ups, even though it's too technical u need to continue this for ur career development

Nice write up. All the best Sai...?

Good start. Expecting more technical writeups..

要查看或添加评论,请登录

Balanarasimhan R的更多文章

社区洞察

其他会员也浏览了