getData(dataViewName, payload, context, options)
Retrieves the list of data records in a data view.
Returns
The response as a Promise.
Parameters
Name | Type | Description | Required |
dataViewName | string | The name of the data view from which the list of data records must be retrieved. | ✅ |
payload | object | A query object containing the details of list of columns, filter conditions, and pagination to be retrieved. | ❌ |
context | string | The name of the context where the API is being called. | ✅ |
options | object | The object that contains the properties required to perform additional actions while retrieving the list of data records. | ❌ |
The following table contains the properties of the payload object:
Name | Type | Description | Required |
query | object | A command to obtain a set of fields satisfying specific conditions, such as, select, sortBy, filter, etc. | ❌ |
paging | object | An object that obtains a specific number of records from a page. | ❌ |
dataViewParameters | object | An object whose parameters are configured on the data view or data page. | ❌ |
The following table contains the properties of the options object:
Name | Type | Description | Required |
skipClearErrorMessages | boolean | The flag that determines if the previously generated error messages should be deleted. | ❌ |
Usage example
In this example, the API retrieves the first 10 records of employees whose gender is
Male
and whose role is Software
.
const dataViewName = "D_EmployeeList";
const payLoad = {
"dataViewParameters": {
"dept": "Engineering"
},
"query": {
"distinctResultsOnly": true,
"filter": {
"filterConditions": {
"F1": {
"comparator": "EQ",
"ignoreCase": true,
"lhs": {
"field": "Role"
},
"rhs": {
"value": "Software"
}
},
"F2": {
"comparator": "EQ",
"ignoreCase": true,
"lhs": {
"field": "Gender"
},
"rhs": {
"value": "Male"
}
}
},
"logic": "F1 AND F2"
}
"select": [
{
"field": "Name"
},
{
"field": "Role"
},
{
"field": "Gender"
}
]
},
"paging":{
"pageNumber":1,
"pageSize":10
}
};
const context = "app/primary_1";
PCore.getDataApiUtils().getData(dataViewName, payload, context)
.then(response => {
// The response of this API is as shown below:
{
data: [
{
"Name" : "Mark wood",
"Role" : "Software",
"Gender" "Male"
},
{
"Name" : "Gabe Edwards",
"Role" : "Software",
"Gender" "Male"
}
]
fetchDateTime: "2020-06-29T11:06:24.329Z"
pageNumber: 1
pageSize: 10
}
})
.catch(error => {
console.log(error);
});
Previous topic getCaseEditMetadata(caseID, context) Next topic getDataViewMetadata(dataViewName, context)