Data type Understanding and Cascading control tutorial

In this blog article – first, we will understand the data layers and then in detail about configuring a data type, followed by a short tutorial on Implementing Cascading control.

This article was created using Pega '24 version.

In Pega database, we can have three types of instances in the two schemas – rules and data.

1. Rules schema – holds are the rule instances.

2. Data schema – holds work (case) instances and data (business data + configuration data) instances

Class is a Object oriented rule in Pega and is kind of the backbone for the Pega platform.

In Pega, we can have three type of class layer.

a) Work class – You can create work specific rules in Work- inheriting Applies to classes and on the business data side, Work class holds the case instances like Mortgage-1, 2 etc.

b) Data class – You can create Data specific rules in Data- inheriting Applies to classes and on the business data side, Data class can hold the data instances like Countrieslist as well as can help with embedding data (user data collection from forms)

c) Integration class – You can create all your Int specific rules in Int- inheriting Applies to classes. Normally we never save the business data as Integration instances, we usually maps the Integration data to our business data layer.

Note: We know this introduction can be a bit confusing for newcomers, please read it carefully or check with your seniors about rules and business data.

Now let’s go into detail about the data layers.

Let’s only talk about the business data context.

All the data objects apart from work or case objects can be considered as application data objects.

a) The data can be sourced from local pega database from data schema

b) The data can also be sourced from external database. For example – let’s say a organization central database holds all the language codes they operate.

c) The data can just be collected from user forms and embeddeded with the case data.

      Case data – {Customer data { FirstName:Prem}}

Here you don’t need to save this data into a dedicated table as a row entry. Instead, this can always be just embedded directly with the case data.

The data can also be sourced and mapped from external systems via API call. Here again, we don’t want to always save the data into our database, potentially duplicating data with extra maintenance.

From the above 4 examples, we get to know that Data can be sourced locally from database tables or it can just be collected/mapped and embedded within case without database tables.

In our Mortgage application, let’s say we have two data layers – Customer (which we just collect from the user screen and can be just embedded within the Mortgage case) and Country (which we need to source from Database table.

The data layer we will be creating is on Org layer (assume it will be reused). Then it should be Org-Data-Customer, Org-Data-Country.

How to create the data layer?

If you are from old school 😉, definitely you might have started with creating data class layer manually from Records -> SysAdmin -> Class -> Add new

From Pega 7 version, Pega introduced this data types, to manage the data layer creating in a low code way.

When you define a data type, you can actually do/automate a lot of other development steps, making the Pega developer life simple 😊

a) Creating new properties. Including single value as well as aggregate properties.

b) Adding source for the data type (can be called a data table). It also supports importing and exporting data instances.

c) Auto-creating DB table instances in Pega, and mapping to database table PegaData.

d) Creating different data pages to load or process the data layer.

Note: When you define data type from App studio, you also have an option to define the integration layers if the data is sourced from external systems via API call.

For now, we will continue with configuring from Dev Studio.

How do we configure Data type?

Step 1: Go to data explorer and Add data type from the pick list icon on top right corner.

Step 2: Configure the name, class and ruleset.

Make sure to follow these things when you complete the configuration

– Give a meaningful name for your data type

– Choose the right parent class. By default, Pega will point tothe parent class in the inheritance path. You can also direct inherit to different class (normally when you use any frameworks, you will be doing that)

– Choose the right ruleset for your data layer.

In this example, we will create and name the new data type as “Country”.

After submitting modal dialog, you can see your newly created data type added in your data explorer.

Step 3: Click on the Country data type. It will open up the form.

Before checking on the tabs, let’s open the class – MyOrg-Mortgage-Data-Country.

There you can find some key observations.

First, the class is marked as concrete by default. A big learning. When you create a data layer by using data type, it will always be defaulted to Concrete class

Note: Only Concrete class can have instances, Abstract class cannot have instances.

You may get a question, then how do we create an Abstract data class. Either you can create it manually or just change the type after creating via data type.

Keys – are empty now.

Database connection – If you click on the database connection, you will also see that it points to default table and not the dedicated table.

We will visit the same configurations shortly after checking out the different tabs.

We have 6 main tabs here.

We will see one by one.

1. Data Model tab

From the name you can say that we are modelling fields for that data type.

Here you can add fields to the Data type. Adding fields means Pega automatically creates a new property.

We added here two fields for country data type – Country Name and Country Code.

You will see as soon as you add a field, Pega creates a property of the specified type at the back-end.

Click on the ID column link to open the property.

Property was created in MyOrg-Mortgage-Data-Country data  class.

You can use the settings icon to update the data model if needed.

The configuration you do can update the property rule form and can also create a declare expression rule if you use this option of Calculated (read-only)

2. Usage Tab

This tab lists the places where the data type referenced. Currently this is empty. We will check this at the end of this post.

3. Sources tab

This tab lists the sources for the data type. From the introduction, we also understood that data types contain instances.

The instances can be from local sources like Pega database.

Let’s create a local datasource for the Country data type.

Using this wizard, we can automatically create a database table, supporting data pages.

You can also create new columns and choose one of the columns as key.

When you add a new column it creates a new property.

I am going to create a new field as SNo and use CountryCode as Key.

 Remember, here we can specify only single value properties.

Click submit button.

The final step provides what rules are created by the wizard.

a) Database table – Created in Pega database.

Note: If you don’t have privilege to create DB table in SQL, then you will get an option to download it as SQL file. Use DBA admin help to create a table.

b) Class rule – The data class layer.

c) Database table class mapping rule – Pega DB table instance.

d) Report Definition – Supports adding rows manually (we will see it soon).

e) 3 data pages – Single page, Page list and Savable data pages.

f) Property rules, during the column configurations

4. Usage tab

Refresh and check the Usage (Close it open again).

You can see the data pages created are listed here.

5. Records tab

Remember if no source is defined, then we can add a new local data source here. The modal dialog used is as same as we create from Sources tab.

Here you can add records (Instances) to the data source you added.

Use edit column button to edit the columns – add new column.

Use show database information to views the DB table details.

You can add the record individually or also import and export data.

Use the Add record link to add a new instance manually

Now let’s try to update the record using Import Excel option.

First, let’s do the export part to create the Excel file with the existing records

Open it in any other editor and try adding rows or updating existing rows..

I am adding a new row for the Netherlands

Save and Import the file

Complete the wizard steps

You can use the purpose as Add or Update

The other details in the wizard are kind of self-explanatory.

You can also run the validation to make sure if the data entered is of right data quality.

As a final step, you can click on continue import to import the new entry into the data type

You see the new entry successfully added to the data type

6. Views tab

You can create UI views/section for the data type.

These sections can be directly embedded to the work UI if needed

What are the actions that you can take from data explorer?

After creating a data type, you can take the following actions.

View Definition – Open the data type form.

Rename – You can rename the data type.

Add data page – You can add a new data type.

Remove from application – Removes the data type and associated rules from the application.

How to Implement Cascading Control?

Scenario: You are filling out a form. There are 2 fields configured as dropdowns:

  1. Country
  2. State

When you select a particular country, the state dropdown should be updated respectively to that country.

This can be technically called cascading control.

We will see how we can implement this.

Step 1: Configure a section with dropdown control.

Step 2: Set the source as data page D_CountriesList.

Step 3: Check in the UI.

Now Countries List is ready.

Step 4: Create a new data type for the state and create a local storage.

Step 5: Modify the D_StateList data page to accept country code as parameter.

Modify the Source of the data page to accept parameters – here Report definition.

Remember to check pass parameter page in data pages sources field.

Step 6: Add a new field for state and configure to accept the D_StateList data page with country code as parameter.

Step 7 : Check in the user portal.

Now we can cascade control using data type. 🙂

A technical team dedicated to empowering the Pega ecosystem with in-depth knowledge, guided by Premkumar Ganesan's vision.