When I open the contact form and then select activities from the navigation bar, the associated activities view appears. Is there a way to get the name of the subgrid for this view? I
var subgrid = Xrm.Page.getControl(<sub-grid name>);
Note: This is unsupported customization.
Getting Associated view grid is different from subgrid in entity forms. Subgrid in CRM form is accessible using Xrm.Page.getControl(subgrid_name)
like any other control.
But to access Associated view grid, you have to do DOM manipulation starting from IFRAME, then Grid like below.
To get the IFrame control:
var frame = document.frames[“areaActivitiesFrame”].frameElement;
To refresh the associated grid view:
frame.contentWindow.document.getElementById(“crmGrid_Account_ActivityPointers”).control.refresh();
Once you get the control, try to override the click event like explained in SO thread