How to set single-value properties of a class using an Activity rule in Pega (PRPC)

Coach Abhishek
5 min readJan 23, 2023

--

Activity rule is one of the widely used rule types in any application developed with PegaRules Process Commander (PRPC) due to its versatile nature. It can be used for implementing business rules, computation, data manipulation and many other purposes.

However, as a best practice, the use of the activity rules should be limited, and avoided wherever possible to deliver high-performing Pega applications. There are certain areas that still require the use of the activity rule, for example — Agents, Job Scheduler, Queue Processor, Service rules, Declare Trigger, Declare On Change, and others. In view of this fact, it becomes critical for a system architect to be well-versed in the activity rules.

One of the most basic and commonly used action in an activity rule is to set values to properties of a class. Let’s look at how it can be accomplished in a simple way.

If you’re interested in knowing how to achieve the same using a data transform rule, you can read the below article.

Step# 1: Create a Class rule and Properties

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

For the demo purpose, I’ve created a new concrete Data class named MyOrg-Data-Customer that inherits from Data- class (predefined 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 predefined property rules that are inherited from the parent class in order to avoid creating new property rules.

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

Step# 2: Create an Activity rule

Secondly, you need to create a new Activity rule wherein you’re going to create a new Page (essentially, a class object) of the above-mentioned Customer class and set the property values on that page.

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

CreateCustomer activity applied to the Work class

Step# 3: Define the logic in the Activity rule

Thirdly, you need to write the logic in the activity rule to set values to the properties.

For this purpose, you need to use the PROPERTY-SET activity method and specify the PROPERTY NAME and PROPERTY VALUE as the method parameters.

I’ve used PAGE-NEW activity method in the first step to create a new page (essentially a class object) named Customer1 of the above-mentioned MyOrg-Data-Customer class.

Page-New activity method

I’ve specified the page class in the Pages & Classes tab of the activity rule as shown below.

Pages & Classes tab

Then I’ve added another step in the Steps tab. I’ve used Property-Set method in this step, and have listed the property names and the corresponding property values as shown below. I’ve set values to the following properties — CustomerID, pyName, pyEmailAddress, pyCity and pyState. Please note that I’ve specified Customer1 as step page of the Property-Set step in order to set the property values on this page.

Property-Set activity method

After you’re done, do not forget to save your activity rule.

Step# 4: Run the Activity

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

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

Run the activity

On the window that pops up, click on the RUN button

Run the activity

If there’s no runtime error, you will see a success message on another pop-up window as shown below

Success message

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 find the page.

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

Clipboard view

Likewise, if required, you can create more pages (aka objects) such as Customer2, Customer3, etc. of the same class and set the property values on them as shown below.

Set property values on Customer2 page

Remember to list the additional pages in the Pages & Classes tab along with the class name.

Pages & Classes tab

--

--