Saturday, September 29, 2018

How to change key of class which already has intances

Context:

Let's assume that there is Employee class in Pega
Class Name: MyOrg-MyDiv-Data-Employee
Database Table: org_employee
Already there are 1000 records existing in the database table mapped to this class.
Now if we have requirement to add one more property as part of the class key. How can we do it ?

- We can delete all the records from database table, then Pega would allow to change the keys.
- Since deleting the records is not a good option, what is the alternative ?

Solution:

  • Open class rule definition. We could notice the existing keys.
  • Open Database Table instance rule corresponding to this rule. It will show org_employee.
  • Change it to pr_other. Go back to class rule definition, refresh it. It would allow us to add one more column as part of key. Save it. 
  • Then again navigate to Database Table instance rule and change the table back to org_employee. 
  • Once these changes are done. Go back to class definition and click on Test Connectivity.

Now we have added one more column as the key without removing any records from the table.
During deployment to higher environment, we need to send both the Class and Database table instance.



No comments:

Post a Comment


HowToPega : All rights reserved and the contents are copyrighted to Pavan Kumar Naidu