ExpandDefinition
Defines how related records are expanded in a query. This is an object where keys are navigation properties and values are either an array of properties to select or another ExpandDefinition object.
function expandDefinitionSample() {
const client = Hsl.WebApi.getClient('9.1');
const getSettings = {
formattedValues: true,
// This controls how many records appear in expanded 1:N relationships. Additional records will be accessible
// using @odata.nextLink. Default if not specified is 5000.
pageSize: 10,
};
return client.retrieve({ entityType: 'account', id: '{F99A0E3E-90D5-EA11-A813-002248049FFB}' }, ['name'], {
primarycontactid: ['fullname', 'emailaddress1'],
owninguser: {
select: ['fullname'],
expand: {
territoryid: ['_managerid_value'],
},
},
opportunity_customer_accounts: {
select: ['name', 'estimatedvalue'],
filter: 'statecode eq 0',
orderby: 'estimatedvalue desc',
expand: {
msdyn_AccountManagerId: ['fullname', 'internalemailaddress'],
},
count: true,
},
Account_CustomerAddress: ['line1', 'line2', 'city', 'stateorprovince', 'postalcode'],
}, getSettings).then(account => {
console.log(account);
const opportunityNextPageLink = account['opportunity_customer_accounts@odata.nextLink'];
if (opportunityNextPageLink) {
return client.get(opportunityNextPageLink, getSettings); // Gets accounts for the second page.
}
return undefined;
});
}