How to create a Data Type in Pega (PRPC) Platform Application and add data records

Coach Abhishek
6 min readFeb 4, 2023

--

Data Types are used in Pega to store static application data. For example, there could be a dropdown list on a form for user to select the city in which he or she lives. The different choices or options available for the user to select from, such as — Delhi, Mumbai, Kolkata, Chennai, etc. constitute static application data, and can be stored as records in a data type.

It is important to note that the data types are linked with a database table. Any record added to the data type is basically stored as a row in the associated database table.

In some old versions of PRPC, such as — v5 and v6, data tables are used in place of data types. Data tables look very similar to data types, and serve the same purpose of storing static application data.

Let’s look at the method to create a new data type in your Pega platform application, and manually add data records to it.. I’m going to demonstrate by creating a data type to store records of different users of my Pega Platform application.

Part A — Create a Data Type

To start off, go to Data explorer in the left navigation panel, and then click on the inverted caret symbol in the top right corner, and finally select Add data type option from the menu as shown below.

Add Data Type option in Data Types explorer

It would open up a modal dialog, as shown below, with New Data Type radio button pre-selected. Enter relevant values in the Label and Description fields. The label serves as the name of the data type.

Add Data Type modal dialog

After you’ve entered the label and description, click on the right angle bracket symbol (>) besides Advanced in the above dialog. It would display a section, as shown below, to select Parent class, app layer and ruleset of the data type.

Add Data Type dialog — Advanced Configuration

The parent class can be chosen depending upon the layer (organizational, division, unit, framework or implementation) in which you want to create your data type. I want to create my data type in the organizational layer, so that it is accessible across the organization. For this reason, as shown below, I’ve selected MyOrg-Data (the data class in my organizational layer) as the parent class.

Insight — Notice the Identifier value shown immediately below the parent class name. As obvious, the identifier of your data type is derived from its parent class and it represents the class of your data type. The records that you would add to your data type, would be objects of the same class.

Note — Since, you’re creating a data type, make sure to select a data class, and not a work class, as its parent class.

I’ve chosen my application (Beta) as the app layer for the data type. Finally, I’ve selected to add the data type to my application ruleset (Beta). You can choose these values as appropriate in your case.

Add Data Type dialog — parent class and ruleset configuration

After you’re done, click on Submit in the above dialog. It would close and open your newly created data type in a new tab as shown below.

New Data Type created

Once created, your data type would be visible in the Data types explorer as shown below.

New Data type available in Data explorer

Part B — Add fields to the data type

Before we add data records to the data type, we need to add fields to it. To add a field, click on the Add field button in the Data model tab. It would open a modal dialog as shown below. Enter a Field name, select a Type for the field, and click on the Submit button in the dialog.

Add field — Modal dialog

You can select a field type from a number of available ones. Text (single line), Integer, Decimal, Boolean, Email, Phone, Date Only, Date & time, and Picklist are some of the commonly used types.

The picklist type allows to display the field as a drop-down list or a search box or radio buttons while adding data records. The choices or options to be included in the drop-down list or search box can also be defined in the same dialog as shown below.

Picklist field type

You can add as many fields as you require to your data type. I’ve the following fields that define a user to my data type.

Data type with fields

Insight — For each field added to the data type, PRPC automatically creates a property in the data type class (MyOrg-Data-User in my case) as well as a corresponding column in the database table linked with the data type. The auto-generated properties can be viewed in the App explorer as shown below.

Properties generated in the Data Type class

Part C— Add data records to the data type

By adding records to a data type, you’re basically creating rows in the linked database table.

Insight — The records added to a data type, are essentially objects of the data type class (MyOrg-Data-User in my case).

To add records, switch to the Sources tab and click on the Create a local source button as shown below.

Sources tab

This would open a modal dialog as shown below, wherein you can select one or more fields as a key to uniquely identify the records, and optionally enter the values of the fields for the first record. In my case, I’ve chosen User ID as the key.

User ID selected as the class key
Values for the first record

Click on the Submit button in the dialog. It would bring up a review screen as shown below.

Review screen

X-out of the above screen, and switch over to the Records tab. The first record would be visible therein as shown below.

Records tab

You can add as many records as required by clicking on the Add record link immediately below the first record, and filling the values in the fields.

Another added record

Note — PRPC automatically generates three data pages — a single-page structured, a list structured, and a savable mode data page as shown below, for you to create, update and read data records from your data type programmatically at runtime.

Auto-generated data pages

Insight — To find out or change the database table linked with your data type, go to the SysAdmin -> Database Table in the Records explorer, and filter the instances with your data type class (e.g. MyOrg-Data-User).

From the results, open the instance specific to your data type. It contains the associated table name as shown below. If required, the data type can be linked with a different table from here.

--

--