You are here:
fetchWithParams Function
Queries data that’s not already returned in Mustache variables, and returns results to the specified callback method.
Required Editions
| Available in: Lightning Experience |
| Available in: Enterprise and Unlimited Editions with Life Sciences Cloud, Life Sciences Cloud for Customer Engagement Add-on license, and the Life Sciences Customer Engagement managed package. |
You can query the User, Account, Record Type, Territory2, UserTerritory2Association, Life Sciences objects, and custom objects. To query records:
- Assign Read permissions on the queried objects and fields to the user.
- Create active object metadata cache configurations exist for each object and sync them to the Life Sciences Cloud mobile app.
Syntax
PresentationPlayer.fetchWithParams(query, params, callbackMethod)Arguments
| Argument | Description |
|---|---|
query |
The SOQL query as a string, or the query locator value for subsequent fetches. You can include Mustache variables within queries. In the
The WHERE clause supports:
|
params |
Optional. The ability to specify the batch size. In the Each call can return a maximum of 100 records. |
callbackMethod |
The name of the JavaScript method that receives the query results. |
Returns
This function returns a JSON result.
| Field Name | Type | Description |
|---|---|---|
records |
Array<Object> | The result data. |
done |
Boolean | Indicates whether all data has been queried (true) or not
(false). |
totalSize |
Integer | The total number of records processed in the query. |
queryLocator |
String | A unique SQL identifier that can be used in future requests. |
state |
String | The request status, such as success or error. |
Usage
Regardless of batch size, queries can return a maximum of 100 records. This example sets the batch size to 75 records.
PresentationPlayer.fetchWithParams('SELECT FirstName, LastName, Name, Email, Phone, Username FROM User WHERE Id = ' + userId', {'batchSize': 75}, getCurrentUserRecordCallback');If you don't specify the batch size, the fetchWithParams function queries 15
records by default. To query additional records when using smaller batch sizes, use the
queryLocator variable.
This example uses the queryLocator variable.
function getAccounts() {
PresentationPlayer.fetchWithParams('SELECT Id FROM Account', {'batchSize': 15}, 'getAccountsCallback');
// Return 15 records
}
function getAccountsCallback(data) {
// Process records
PresentationPlayer.fetchWithParams(data.queryLocator, 'getAccountsCallback');
}Example
<script type="text/javascript">
var configData;
document.addEventListener('PresentationDOMContentLoaded', function(event) => {
configData = event.data;
function getCurrentUserRecord() {
let userId = ' \' ' + configData.parameters.id + ' \' ';
PresentationPlayer.fetchWithParams('SELECT FirstName, LastName, Name, Email, Phone, Username FROM User WHERE Id = ' + userId, {'batchSize': 75},
'getCurrentUserRecordCallback');
}
function getCurrentUserRecordCallback(data) {
if (data.state === 'success') {
const html = data.records.map((el)=>{
console.log('User Name: ', el.Name);
console.log('User Email: ', el.Email);
});
} else {
PresentationPlayer.alert(data.message + '\n' + data.code);
}
}
</script>Errors
This function returns an error when:
- The query can’t access or find a record.
- A SQL error occurs.

