Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

getData(dataViewName, payload, context, options)

Updated on July 20, 2021

Retrieves the list of data records in a data view.

Returns

The response as a Promise.

Parameters

NameTypeDescriptionRequired
dataViewNamestringThe name of the data view from which the list of data records must be retrieved.
payloadobjectA query object containing the details of list of columns, filter conditions, and pagination to be retrieved.
contextstringThe name of the context where the API is being called.
optionsobjectThe 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:

NameTypeDescriptionRequired
queryobjectA command to obtain a set of fields satisfying specific conditions, such as, select, sortBy, filter, etc.
Note: This property is applicable only when the Allow API query checkbox is enabled in the data page rule form.
pagingobjectAn object that obtains a specific number of records from a page.
Note: This property is applicable only when the Allow API query checkbox is enabled in the data page rule form.
dataViewParametersobjectAn object whose parameters are configured on the data view or data page.
Note: This property must be provided when the data page has required parameters.

The following table contains the properties of the options object:

NameTypeDescriptionRequired
skipClearErrorMessagesbooleanThe flag that determines if the previously generated error messages should be deleted.
Note:
  • The default value of skipClearErrorMessages is false.
  • If skipClearErrorMessages is true, the error messages will not be deleted.
  • If skipClearErrorMessages is false, the error messages will 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);
});

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us