Hello community,
I'm having issues with implementing an advanced filter on a Subgrid (entity 'email', shown on a 'contact' form as the subgrid 'emailGrid').
What I'd like to do is show all e-mails that contain the emailaddress1 of the current contact record, even if it's related to the systemuser of the same person.
To do so I've built a fetchXml query in the FetchXML Builder:
However, I'm facing two issues with that query that I hope someone will be able to help me with:
a) When I add this to the subgrid, the grid itself tells me that "Link entity with name or alias contact is not found". I've tried using different alias (eg "ac" for the contact, "asu" for the systemuser) to no avail. The query works perfectly fine (aside from not being able to enable 'distinct' and therefore showing duplicate records) from within FetchXML Builder.
function updateSubGrid(executionContext) {
var formContext = executionContext.getFormContext();
//var mailGrid = document.getElementById("emailGrid");
//var mailGrid = window.parent.document.getElementById("emailGrid");
var mailGrid = formContext.getControl("emailGrid");
if (mailGrid == null) {
console.log("mailGrid does not exist, retry in 1s.");
setTimeout(function () { updateSubGrid(executionContext); },1000); // wait a second for the grid to load, then retry
return;
}
var emailAddress = formContext.getAttribute("emailaddress1").getValue();
console.log("set filter to emails from/to this email: " emailAddress);
if (emailAddress == null) return;
var fetchXml = ""
""
""
// Columns to retrieve
""
""
""
""
""
// Filter based on emailAddress through both linked entities
""
""
""
""
// Order by sent date
""
// Link to activityparty
""
// and link to Contact and Systemuser
""
""
""
""
""
""
""
""
"";
console.log(fetchXml);
mailGrid._gridControl.setFilterXml(fetchXml);
console.log("filter was set, refreshing grid.");
mailGrid._gridControl.refresh();
}
b) When I try adding distinct='true' to the query, FetchXML Builder tells me "An unexpected error occured." without telling me what kind of error, then offers to try as ExecuteFetch, which DOES work.