-
Notifications
You must be signed in to change notification settings - Fork 1
SystemQueryOptions
Niels Steenbeek edited this page Mar 24, 2020
·
4 revisions
The SystemQueryOptions interface wraps the complex, hard to read and hard to write $select and $expand.
The select is an array of Entity field names. When the field name is a lookup, the code will automatically rewrite to: _fieldname_value.
The expand is an array of NavigationPropertyNames. Those are a little bit hard to find. Most times they are equal to the Schema Name and otherwise use /api/data/v9.1/$metadata to find the matching . A nested expand is not possible due to D365 restriction.
interface Expand {
attribute: string;
select: string[];
}
export interface SystemQueryOptions {
select: string[];
expands?: Expand[];
}
const entity = formContext.data.entity,
id = entity.getId(),
options: SystemQueryOptions = {
select: ['name']
},
account = await AccountService.retrieveRecord(id, options);
console.log(account.name);
const entity = formContext.data.entity,
id = entity.getId(),
options: SystemQueryOptions = {
select: ['name'],
expands: [{
attribute: 'owninguser',
select: ['firstname']
}]
},
account = await AccountService.retrieveRecord(id, options);
console.log(account.owninguser.firstname);