Hello, on the Account Form I have a subgrid that shows quotedetails (the custom direct relationship is already setup. The requirement is to show the quotedetails of all the Accounts in the Account Hierarchy in the subgrid. After various methods, I have gotten the closest with using a plugin that uses RetrieveMultiple to edit the FetchXML and return the filter I need. It works with the hierarchy filter, however, only when hardcoded. I have to set the subgrid to Show All Records, not show Only Related Records, because I need it to show quotedetails from other Accounts, i.e. Child Accounts. Because it is Show All Records, the plugin doesn't have any context of what Account the User is on when the RetrieveMultiple gets the FetchXML. So, I need some way for the Form to communicate to the plugin the Account ID of the form that the user is on. If I can get that step done, then it should work!
Some methods I have tried that didn't work:
- doing all the filtering in javascript. This works until the User interacts with the subgrid to filter by column, and then that filter overrides the javascript FetchXML.
- there is an Under condition in FetchXML that appears to work for hierarchies, but I got a message that it was unsupported when I tried that method in this scenario.
Here's an example of how I have tried to smuggle the GUID into the FetchXML using javascript, which hopefull I can get the Plugin to catch. However, the plugin does not seem to see the GUID.
Does anyone have any ideas for how to pass the GUID from clientside over to the Plugin, and what the best approach is here?
function passAccountGuidToPlugin() {
var accountId = Xrm.Page.data.entity.getId();
Xrm.Page.getControl(/HierarchyTest/).addPreSearch(function() {
addCustomFilterToSubgrid(accountId);
});
}
function addCustomFilterToSubgrid(accountId) {
var fetchXml = /<filter><condition attribute='new_account' operator='eq' value='/ + accountId + /' /></filter>/;
Xrm.Page.getControl(/HierarchyTest/).addCustomFilter(fetchXml);
}