Hello Experts,
is it possible to display Contacts from a Parent Account in a Child Account?
I found some JavaScript Code but only for Display Contacts from a Child Account in a Parent Account.
Can i use this code and rewrite it for the Parent Account?
function GetContacts() {
// get Contacts Sub grid
var accountChildContactsGrid = window.parent.document.getElementById("whatever your sub grid name is")
// Get the ID of the current account
var rootAccountID = Xrm.Page.data.entity.getId();
// Check that the subgrid is ready
if (accountChildContactsGrid == null){
setTimeout('GetContacts()',1000);
return;
}
// Construct FetchXML for contacts in this account and its child accounts
var fetchXml = "<fetch version='1.0' mapping='logical'>";
fetchXml += "<entity name='contact'>";
fetchXml += "<attribute name='fullname'/>";
fetchXml += "<attribute name='emailaddress1'/>";
fetchXml += "<order attribute='fullname' descending='false' />";
fetchXml += "<link-entity name='account' from='accountid' to='parentcustomerid' link-type='inner' >";
fetchXml += "<filter type='and'>";
fetchXml += "<condition attribute='accountid' operator='eq-or-under' value='" + rootAccountID + "' />";
fetchXml += "<condition attribute='accountid' operator='not-null' />";
fetchXml += "</filter>";
fetchXml += "</link-entity>";
fetchXml += "</entity>";
fetchXml += "</fetch>";
// make sure control is ready and set data and refresh the subgrid
if (accountChildContactsGrid.control != null){
accountChildContactsGrid.control.SetParameter("fetchXml", fetchXml);
accountChildContactsGrid.control.refresh();
}
else{
setTimeout('GetContacts()',1000);
}
Thank you for your Help.
Regards
Léon





