Data type and Cascading control example in Pega

Introduction

Data type is a generic term to include any data instances.

Pega have many inbuilt data instances.

  • Access groups, class group, organization, unit etc., are all data instances.

Note: Data instances cannot be locked and they don’t belong to any ruleset version.

Go to App explorer and type Data-Admin-

You can see some list of Inbuilt data types.

We will see how we can add new data types as well as existing data types to the application.

  • If you have worked in Pega 6 versions, you should have come across a term ‘Data table’ to hold the instances for Internal pega table. It can also be mapped to external table via class mapping.
  • In Pega 7, this have been modified to Create a data type and add local storage for the same.

In simple words, Data type is just a class type which contains data instances.

You may think, “Why can’t I just create a concrete data class?

Yes, you can. But this data explorer – Data type supports automating the following process:

  1. Create new properties. Includes single value as well as aggregate properties.
  2. Add source for the data type (can be called a data table). Supports importing and exporting data instances.
  3. Create DB table instances in Pega, and maps to database table PegaData.
  4. Create data pages for these data instances.

Now, what do you say? Creating data type and managing makes the developer life simple 🙂

What is a data type?

  • It is a data layer for an application.
  • This data layer contains data instances specific to particular type.

Imagine a Call Center organization. We are customers to that organization. Now they use Pega CRM application.

Think and say, “What can be the primary data type for that application? – Yes, Customers.

I can have a data type as customer. I can have new properties, separate table, data pages to access.

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.

You can create a new data type as shown above or existing data types as shown below.

Existing data type means you can add any existing class as data type.

In this example, we will create a 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.

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 mean Pega automatically creates a new property.

We added here fields for country data type.

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

  • Click on the ID link to open the property.

Property gets created in XYZ-Data-Country data  class.

You have an option to choose data type for the property.

There are simple types, fancy types and complex types.

  • Field group, field group (list) creates Page, Pagelist properties.
  • Data reference, Data reference (list) refers another data type.
  • Simple type normally creates text, Int type with appropriate control.
  • Once created you can change the type.

It can be simple calculate like cost * quantity or some complex calculation using declare expression rule.

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. We know data types contain instances.

The instances can be of any source.

If no source is defined, then for our case, we can add a local data source.

On clicking ‘Create a local source’, we get a wizard.

What is a local source?

  • We can configure the data source as local and no need to manually create a database table.

Here we can specify the key column as well as add new columns.

  • Adding new column creates a new property.

I am going to create a new field as SNo. Remember, here we can specify only single value properties.

  • Click submit button.

The next 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) Database table mapping rule – Pega DB table instance.

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

d) 2 data pages – Single page & Page list.

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

You can see the data pages created are listed here.

4. 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 also import and export data.

Importing process

Step 1: Clicking on the import link from right corner, opens up a wizard in modal dialog.

You can either add/update records. Upload a .csv file.

Step 2: Specify mapping between .csv columns and data source columns.

Select update type as ‘Always Update’, and Match existing records by – SNo

Source field – Column heading in .csv file.

Target field – Local source column name.

Step 3: Finish the mapping and move to next step.

Skip data type validation – Skips the validation process, improves import time.

Customize date time – You can specify the format for date time.

Save template as – You can specify a name and save it as a template.

Click on import, to complete the process. You can verify that the records are imported successfully.

You can verify it in records tab.

Export process

Step 1: Click on the Export link on the right top.

You will get the default download option.

Step 2: You can open or save the .csv file to local disk.

Apart from import process , you can manually add the records.

  • Prefer using import process when we need to add/ update more rows.
  • If we need to add less number of rows prefer adding manually.

2. Usage tab

Data pages – Lists the data pages that use data type.

Property references – Properties that reference this data type – currently null.

Undefined pages – Lists the undefined pages used in activities, DT that reference the data type.

5. Test Cases tab

You can test cases for the data pages.

Step 1: Click ‘Add new’ and select a data page.

Step 2: You will get a popup window with ‘run’ button and parameter for the selected data page.

Step 3: Run it. You will have an option to convert it to test case.

Step 4: Test case instance is created. Save and close.

Step 5: Check the test cases tab. You can use this to check if the data page meets the expected requirement.

6. Settings tab

You can specify the description as well as context for new rules. New rules (properties) we create will be saved in the selected ruleset.

Shows the database details.

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

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

  1. View Definition – Open the data type form.
  2. Rename – You can rename the data type.
  3. Add data page – You can add a new data type.
  4. Remove from application – Removes the data type and associated rules from the application.

Let’s test it with an Cascading example.

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

  1. Country
  2. State

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

This can be technically called as 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 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 are able to cascade control using data type. 🙂

9 thoughts on “Data type and Cascading control example in Pega

  1. Pega creates a property for field that added to data type. Can’t we add existing properties to new data model chudu instead creating new one? . For example : Process has three data models , and we have a generic properties (Created by,CreatedOn etc) that needs be added to each data model .if we keep them in each specialized data layer then it would be violating reuseability .

    1. Exactly Brahmesh. Good question. Pega needs to care about reusing the properties in data type.😊 Hopefully in new releases they can implement the same.

    2. Hi Brahmesh,
      Now also if a property is existing, pega won’t create it in that particular data class, it will reuse it.For an existing property, a small rocket sign gets dispalyed if you add it .
      I hope you got my answer.

  2. Hey nice article ..Couple of things :
    1. data reference and data reference list are also page and page list properties respectively . The basic difference between field group and field group list are data population . For data reference /data reference (list) data will be populated via data page . So for any page and page list property you get three options :
    a. Manual
    b. Copy of a Data page
    c. refer to a Data page

    field group / field group (list) sourced as Manual i.e. user has to take care of data population
    Data Reference /Data reference(list) sourced as ‘Refer to a data peg’ i.e. automatically data will be populated based on DP value. Data reference (list) is also known as autopopulate property .

    2. Once a property is created we can change property type (like text to integer) based on certain criteria not all the time . If data type is having data instances we cant change . and change property db column should be compatible with new property type.

    3. We can reuse any parent property in child class . Click on filter and check ‘Show inherited’ under data model tab. It shows you all hierarchical properties .
    Small correction from Rahul’s comment. If we reuse any parent property in child class , new property gets created in child class context

  3. Nice Article …..

    I have a small doubt, can we have auto generated primary key here or can we make any property as a auto generated one.

    1. Thanks Yuvansh. I don’t think we can have a auto generated primary key for data type. Can someone share your comments 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *