Skip to content

Instantly share code, notes, and snippets.

@melamriD365
Created February 28, 2020 11:14
Show Gist options
  • Save melamriD365/47e245075e70054fb8e84aebbdee8566 to your computer and use it in GitHub Desktop.
Save melamriD365/47e245075e70054fb8e84aebbdee8566 to your computer and use it in GitHub Desktop.
function DisplayAllChildAccounts(executionContext) {
var formContext = executionContext.getFormContext();
var accountId = formContext.data.entity.getId();
var childAccountGridContext = formContext.getControl("ChildAccounts");
if (childAccountGridContext == null) {
setTimeout(function () { getAllChildAccounts(executionContext); }, 2000);
}
else {
var fetchData = {
accountid: accountId
};
var fetchXml = [
"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>",
" <entity name='account'>",
" <attribute name='name' />",
" <attribute name='telephone1' />",
" <attribute name='address1_city' />",
" <attribute name='primarycontactid' />",
" <attribute name='statecode' />",
" <order attribute='name' descending='false' />",
" <filter type='and'>",
" <condition attribute='accountid' operator='under' value='", fetchData.accountid, "'/>",
" </filter>",
" </entity>",
"</fetch>",
].join("");
console.group(fetchXml);
childAccountGridContext.setFilterXml(fetchXml);
childAccountGridContext.refresh();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment