How to Change the Class instances(Rule-Obj-Class) from one associated ruleset to other ruleset?


        Pega provides lot of tools/utilities inbuilt and wizards to make work easier for administrators and developers. Have you ever faced a scenario in your project to change the associated ruleset of Class rule? I believe this scenario does not happen often but what to do if  it occurs😕 Do you have any utility or wizards to accomplish this task?

       Also, as we already know that it is not much easy to delete the class rule instance as it could have  other dependent classes.  Sometime architects would have to change their design due to certain constraints or move the associated rule of Class rule to other ruleset. Let's assume you want to change the associated ruleset of 10 classes to new ruleset. How it can be done ? 

    In this post , we are going to see how to change the class instances  from one associated ruleset to other ruleset using activity. You can use this activity as a utility and extend further if required.

Activity Design:

In order to change the ruleset name and created version in a class rule,  we need to identify the properties that stores those values in Class rule. Here are below 2 properties which stores the required information.

  1. pyRuleSet-> holds the Ruleset associated with the Class rule
  2. pyInitialVersion-> holds the created in version for a Class rule
In order to use the activity as a utility to change the associated ruleset of class rule for multiple classes, I have parameterized as much as possible. You can add up the parameters as per your requirement.

Here is the steps to be followed in the activity:

  1. Browse the records of Rule-Obj-Class instance  and fetch the pzInsKey of  the passed parameter Class name.
  2. Loop the pagelist and set the pzInsKey to the Parameter Key.
  3. Use Obj-Open-by-Handle method to open the record.
  4. Set the value for Ruleset to be moved and Initial version to be changed that is passed in the parameter as below.

 

 5. Add the Obj-Save with Write now option to immediately write to database.

Now, you can Open and check the Class rule with new associated ruleset changed and version changed.

Note: pxUpdateDateTime property is used to just to add the updated timestamp information in the rule history.

Implementation:

  The below is the class rule that I have created and going to change the associated ruleset for it.





Next, as mentioned above, I have implemented the above activity and now let us execute.

Before update in Clipboard:

Passing the parameter( Class name or hierarchy, Ruleset name and Initial version)

After update in Clipboard:

Updated Class Rule form:










Now, you can quickly update the associated ruleset and its version for Class rule using above activity. 

Note: You can customize the activity as per your requirement and modify or add any properties to be updated in class rule form accordingly.

I believe this post would be helpful. 

              Thanks!!Keep reading!! Follow and Support us to get more information!! 😊


Popular Posts