Hey everyone, I’m having trouble with Subgrids in Dynamics 365 Online. I want to show phone call and email activities for an account on a Subgrid, but the old method using GridControl.SetParameter() isn’t working anymore.
I’ve tried a bunch of stuff I found online, but nothing seems to do the trick. Has anyone figured out a new way to do this in Dynamics 365?
Hey there, I’ve been down this road before and it can be frustrating. The SetParameter method is indeed obsolete now. Here’s what worked for me:
Instead of messing with the FetchXML directly, I found it easier to create a custom view in Dynamics 365 that filters the activities how you want. Then, you can set this view as the default for your Subgrid.
If you really need to do it via code, try this approach:
var gridContext = activityGrid.getGrid().getContext();
gridContext.setQueryParameters({
fetchXml: encodeURIComponent(customFetch)
});
activityGrid.getGrid().refresh();
This method uses the grid context to set query parameters, which is more in line with current Dynamics 365 practices. Remember to encode your FetchXML to avoid any issues with special characters.
Also, double-check that your FetchXML is correctly formatted. Sometimes a small syntax error can cause big headaches. Good luck with your project!
I’ve encountered this issue before, and it’s a bit tricky. The SetParameter method is indeed deprecated. Instead, try using the setDataXml method on the grid control. Here’s a modified version of your code that might work:
var activityGrid = Xrm.Page.getControl(“AccountActivities”);
if (activityGrid) {
var accId = Xrm.Page.data.entity.getId();
var customFetch = <fetch> <entity name='activitypointer'> <attribute name='subject' /> <attribute name='scheduledstart' /> <filter> <condition attribute='regardingobjectid' operator='eq' value='${accId}' /> </filter> </entity> </fetch>;
This approach uses template literals for better readability. Remember to test thoroughly, as Dynamics 365 updates can sometimes change API behavior. If this doesn’t work, consider creating a custom view as a workaround.