I created a form property script to populate a sub grid on the lead form with all other leads containing the same company name. My script is terminating but the sub grid is still empty. I am thinking it has something to do with my fetchXml.
In other words, the sub grid should show a relationship from one lead to N leads with the same company name.
function setLeadStakeholders()
{
var relatedLeads = window.parent.document.getElementById("lead_relatedbycompany");
var lookupfield = new Array;
lookupfield = Xrm.Page.getAttribute("companyname").getValue();
if(lookupfield == null){ return; }
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
"<entity name='lead'>"+
"<attribute name='fullname' />"+
"<attribute name='companyname' />"+
"<order attribute='fullname' descending='false' />"+
"<filter type='and'>"+
"<condition attribute='companyname' operator='eq' value='" + lookupfield + "' />" +
"</filter>"+
"</entity>"+
"</fetch>";
if(relatedLeads.control != null){
relatedLeads.control.setParameter('fetchXml', fetchXml);
relatedLeads.control.refresh();
}else{
setTimeout(setLeadStakeholders, 2000);
}
}






