Kieran,
I am not sure if this will help in this situation, but I had a similar issue showing the subgrid for contacts associated to the account while in an opportunity form. The subgrid either showed me all contacts if I selected accounts, or none if I selected related because the contacts are related to the account instead of the opportunity. To get around this, I had to override the subgrids results using javascript below.
function updateAccountContactSubGrid() {
var relatedContacts = document.getElementById("ACCOUNTCONTACTS"); // Your Grid Unique Name
var lookupfield = new Array;
var lookupid;
//Get the lookup field
lookupfield = Xrm.Page.getAttribute("parentaccountid").getValue(); // Filter Grid base on the lookup value
//This will get the lookup field guid if there is value present in the lookup
if (lookupfield != null) {
lookupid = lookupfield[0].id;
}
//Else the function will return and no code will be executed.
else {
return;
}
//This method is to ensure that grid is loaded before processing.
if (relatedContacts == null || relatedContacts.readyState != "complete") {
//This statement is used to wait for 2 seconds and recall the function until the grid is loaded.
setTimeout('updateAccountContactSubGrid()', 2000);
return;
}
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
fetchXml += "<entity name='contact'>";
fetchXml += "<attribute name='fullname' />";
fetchXml += "<attribute name='telephone1' />";
fetchXml += "<attribute name='contactid' />";
fetchXml += "<attribute name='new_role' />";
fetchXml += "<attribute name='jobtitle' />";
fetchXml += "<attribute name='emailaddress1' />";
fetchXml += "<attribute name='parentcustomerid' />";
fetchXml += "<order attribute='fullname' descending='false' />";
fetchXml += "<filter type='and'>";
fetchXml += "<condition attribute='parentcustomerid' operator='eq' uitype='account' value='" + lookupid + "' />";
fetchXml += "</filter>";
fetchXml += "</entity>";
fetchXml += "</fetch>";
//Setting the fetch xml to the sub grid.
relatedContacts.control.SetParameter("fetchXml", fetchXml);
//This statement will refresh the sub grid after making all modifications.
relatedContacts.control.refresh();
}
I hope this helps!