ebs.getByQueryAsync
(FintechOS Studio 20.2 and later)
Asynchronously returns a promise of a collection of records based on a query (fetch object). If no filtering conditions are specified, all the entity data will be returned.
HINT
For higher performance, use filtering conditions. This enables you to get only the data that is relevant to you.
For higher performance, use filtering conditions. This enables you to get only the data that is relevant to you.
Syntax
Copy
ebs.getByQueryAsync(fetchObj: IFetch): Promise<any>
Where the Fetch Object has the following syntax:
Copy
{
page: { //select a specific subset of the result set
skip: number,
take: number,
returncount: boolean,
},
entity: {
name: string,
alias: string, //unique alias for the entity. Preceedes entity's attributes' names when referring to them
attributelist: [{
name: string,
alias: string,
}, {
name: string,
alias: string,
}
],
join: [{
type: 'left''inner''right', // inner
entity: {
name: string,
alias: string,
attributelist: [{
name: string,
}]
},
fromto: [{
from: string,
to: string,
}, //join: ... // join from relatedEntity to another childrelatedEntity
]
}, //add another join from masterEntity to another relatedEntity
]
},
orderby: [{ //criteria for ordering the result set
type: 'asc''desc',
attribute: name/alias,
}],
where: {
type: 'or''and',
expressionlist: [{
type: 'and''or',
conditionlist: [{
type: 'contains''etc, posible functions',
first: ,
second: posible options,
}, // add another condition
]
}, // add another expression
]
},
options:{
disableAutoLookupJoins: boolean //disables the auto joins added automatically for lookups and option sets (needed to retrieve the display names)
},
}
NOTE If you want to join data from various entities and use it in form, views, filtered results, charts, etc, you need to:
- Make sure that there are at least two entities in the system.
- Create relationships between the entities on which you do the fetch.
- Add custom attributes to each entity for which you do the fetch; you will use them when defining the fetch.
| Parameter | Description |
|---|---|
entity_name
|
The parent entity, such as entity, attribute, relationship, systemuser, systemusertype, customizationset, businessunit, or portal. |
|
|
Assigns a unique alias for the entity. This alias is used to precede the entity's attributes' names when referring to them. |
filtering_criteria
|
Criteria for filtering the result set. |
paging_criteria
|
Criteria for selecting a specific subset of the result set. |
ordering_criteria
|
Criteria for ordering the result set. |
HINT If you use the Fetch Designer when creating views, the output fetch object is generated automatically and you can copy-paste it into your code.
Response
If the promise is fulfilled, returns an array of JSON objects containing detailed information about each record in the result set. Otherwise, returns an empty array.
Examples
In this example:
- We query all the records in the Account entity.
- For every record, we store each Name attribute in the users array.
- We display the list of users on screen. For details on how to display messages on screen, see ebs.showMessage.
Copy
ebs.getByQueryAsync({entity: {name: 'Account', alias: 't'}})
.then(function(result) {
let users = [];
result.forEach(displayAccounts);
function displayAccounts(item){
users.push(item.t_Name)
};
ebs.showMessage(JSON.stringify(users), "warning")})