How to set properties using a Data Transform rule in Pega (PRPC)

Coach Abhishek
5 min readJan 19, 2023

--

Data Transformation is a critical aspect in an application built using any technology including PegaRules Process Commander (PRPC). PRPC provides two important rule types for data transformation or manipulation —# 1. Activity rule #2. Data Transform.

As a best practice, the developers should limit the use of activity rules and try to harness the power of the data transform rule for data manipulation purposes as much as possible in order to develop performance friendly applications. Having said that, let’s look at how we can set values to the properties of a class using a data transform rule in a step-by-step manner.

Step# 1: Create a Class rule and Properties

Firstly, you need to create a class (Data class or Work class) and create some properties in that class as per your business requirement, if not done already. You can also choose to use some inbuilt properties, such as — pyNote, pyLabel, etc.

For the purpose of demonstration, I’ve created a new concrete Data class named MyOrg-Data-Customer that inherits from Data- class (inbuilt class), and models a Customer entity. I’ve defined Customer ID as the class key to uniquely identify its objects as shown below. And, I am going to use the inbuilt properties that are inherited from the parent Data- class in order to avoid creating new properties.

A concrete class named MyOrg-Data-Customer with Customer ID as its key
A concrete class named MyOrg-Data-Customer with Customer ID as its key

Step# 2: Create a Data Transform rule

Secondly, you need to create a new Data Transform rule wherein you’re going to create a new Page (essentially, a class object) of the same class and perform the data manipulation on that page.

As shown below, I’ve created a new Data Transform named CreateCustomer, applied it to MyOrg-MyDiv-Beta-Work (a Work class). Similarly, you can choose any name for your data transform, that defines its purpose, and create it in any class that best suits your needs.

CreateCustomer data transform applied to the Work class

Step# 3: Define the logic in the Data Transform

Thirdly, you need to define the logic in the data transform rule to set values to the properties.

For this purpose, you need to use the SET action and specify the TARGET and SOURCE values. The property to which you want to set a value, becomes the target. And, the value that you want to set to the property, is the source.

I’ve listed a Page named Customer1 with the same Data class of MyOrg-Data-Customer in the Pages & Classes tab of the data transform in order to create a new page (essentially an object) of this class.

Pages & Classes Tab

Then I’ve used UPDATE PAGE action in the Definition tab of the data transform, and referred the same page therein. This allows me to set the property values on this page. I’ve defined the property names as the target and the corresponding values as the source.

For example — the following lines of code would set a value of “Adam Smith” to pyName property (inbuilt property) and a value of “C-001” to CustomerID property.

SET action with TARGET and SOURCE values

Likewise, I’ve set values to some more properties that define a customer as shown below.

Set the values to other properties

Once you’re done setting values to the properties, Save your data transform rule.

Step# 4: Run the Data Transform

Lastly, let’s run the data transform rule and verify the results on the clipboard.

You can run the data transform by clicking on ACTIONS button, and selecting RUN option from the menu as shown below.

Run the Data Transform

Click on RUN button on the below pop-up window that appears.

Run the data transform

If there are no issues at runtime, a message similar to the one shown below would appear in the same pop-up window.

Run Result

Now, let’s launch the clipboard tool from the toolbar in the footer and look for the Customer1 page therein. You might need to change the thread to STANDARD in the clipboard to locate the page.

Voila! the property values are set on the Customer1 page.

Clipboard view

--

--