Press "Enter" to skip to content

Data type and Cascading control example in Pega

27

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. 🙂

  1. Brahmesh Brahmesh

    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 .

    • Premkumar G Premkumar G

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

    • Rahul Rahul

      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. Mithun Mithun

    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

    • Premkumar G Premkumar G

      Thank you for your valuable points Mithun 🙂

    • sanjeeb sanjeeb

      not able to understand point no 2…how we can change the property type from text-integer once the property has been created ..where is this criteria has been defined??

  3. Yuvansh Yuvansh

    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.

    • Premkumar G Premkumar G

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

      • sabari sabari

        Hi prem can you please upload the step by step procedure for configuring backward chaining….as a fresher this will be helpful for me….

  4. Mahesh Mahesh

    Hi Prem,
    am unable to upload the CSV file. I have installed pega 7.2

    Please help.

    Thanks,
    Mahesh

    • vinod vinod

      make select file name and under select file format as CSV MOSDOS

  5. Ravi verma Ravi verma

    Can we create Local source without assigning a key?

  6. satya satya

    Hi Prem,

    Now i have worked on cascading like country,state,distct,it is wokring fine now i want reverse cascading like if customer select distct automatically it will select state and country also,please help us.

    i will maintain all in single grid only.

  7. Mrinalini Kaushik Mrinalini Kaushik

    from where this .country come from when we pass it as a parameter in 2nd drop down.
    It is not clear to me.

  8. Kiran Kiran

    Hi Prem, Your articles are very good.
    Some connection is missing in this article. Let me tell you that:
    In cascading scenario Step 5, you mention that ‘Modify the source of the Data page to accept Parameters”.

    I am able follow till this step but not able to modify source of Data page to accept parameter. navigation clear in this step. Can you guide me the navigation to ‘Modify the source of the Data page to add parameters. And also update you screen shot, it will help us.

  9. ashok ashok

    Can you please explaine how to move code qt environment

  10. Aaron Aaron

    You say “remember to check pass parameter page…” in the cascading menu section. How in the world do you do that?

  11. Bhargavi Bhargavi

    Hi Prem,
    Your explanations are simply superb. They are so clear with step by step explanations.

    In the cascading example provided in this concept, when I tried to execute the same scenario in my pega personal edition I cannot find ‘Report definition’ as source in data page. I can find remaining options like connectors, Activities, Data Transform, Lookup.

    Could you please help me. Thanks in advance.

  12. yashoda yashoda

    good explanation. please explain about gridlayout

  13. Manjunath Arya Manjunath Arya

    How to accomplish the same Country,State drop downs if we have only one data.

  14. Bharath Bharath

    how can we create test cases??

  15. Mithun Mithun

    Yuvansh we can have auto generated key for data type as well. But you can’t select any property for that . Pega supports only “pyGUID” as auto generated key .
    Before configuring local source , open class definition of the data type.
    Under general tab you will find a checkbox “Automatically generate a unique id for records of this type”. Check that checkbox and save class definition.
    You will see “pyGUID” is set as key
    Now open data designer and configure source . You will find key is selected . Configure local data storage.
    Now in records tab you will see all the exposed properties other than pyGUID .
    This property is kept as hidden in sourced RD named “DataTableEditorReport”
    You add record . Pega adds an unique 16 character hex value for pyGUID for your record.
    To test it, after adding record you export the record and open csv. first column of the csv contains pyGUID value
    Prem you are doing fabulous job.
    Very well written . Keep it up 🙂

  16. Sam Sam

    Hi.. Can you please tell how does the passing a parameter works? How to pass and where is it configured?

  17. Krishna Krishna

    Can you please explain how to create primary key and foreign key relationship between two data types.

  18. Shivaram Shivaram

    Hi Prem,

    This Article taught us a very good knowledge but I have a small doubt.
    As part of Datatype, it has been told that once property is created,you can change the type
    But Can we change the type of the property after creation?
    Because If you go to the property rule form, we cannot change once the type is defined for that.

  19. Surabhi Surabhi

    Very useful article.how can you use parameter and key access together for loading data in dropdown. Like u declare a key in data page. And then if a property has data page as reference, how will data load? Can you please give an example here with screenshots for that?? Thanks in advance.

Leave a Reply

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

error: Content is protected !!