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:
- Create new properties. Includes single value as well as aggregate properties.
- Add source for the data type (can be called a data table). Supports importing and exporting data instances.
- Create DB table instances in Pega, and maps to database table PegaData.
- 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.
- 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.
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.
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.
- 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.
Let’s test it with an Cascading example.
Scenario: You are filling a form. There are 2 fields configured as dropdown:
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. 🙂