Monday, 9 March 2020

How to map a class to a table in Pega


How to map a class to a table in Pega

Hi All, In this post we will see how to map a class to a table.

In below Image you can see the class structure. Under Work class we have Build, Customer, Purchase Request Class.


  •   Build-BuildApp-Work
    • Build
    • Customer
    • Purchase Request


We will create a new table for Purchase Request Class.Right Click ClassName and Select definition to Open Class definition.


Purchase Request is a Concrete Class.


How to know which table this class is mapped to?

By clicking the Test Connectivity we can know which table this class mapped to.




Once we click Test Connectivity a pop-up will open there we can know the table mapped to.

For now purchase request class is mapped to pegadata Schema and the table name is pc_Build_BuildApp_Work table.




I used Postgresql database tool to View my table data.

Link to download pgAdmin 4 :



In pgAdmin website we have demo, which will help us to understand how to Use this software.

We have to provide Host URL then password to login into this software.


Now we will see how to create table in pgAdmin.

We don’t have any option to create table from Pega side. We have to create table from Database tool.

Open the list of Pega table from pgAdmin. DataBase -> Pega - > Schemas - > PegaData - > Tables.



Click on the Work Class(Build-BuildApp-Work) table. After that click SQL tab, there we can see the Create Table sql query. Copy this sql query and paste it in a text editor for some modification.


Changes 1:

Append PurchaseRequest where ever needed.

Changes 2:

Changes 3,4 and 5:



Copy the modified SQL Query and Paste it in Query editor. Run the Query.




Query Executed successfully . So table creation completed.




In Below Image we can see the created table.




Now we have to create a new DataBase table Instance rule in Pega for Mapping Purchase Request class to newly created class.




Create a new Database Table instance.



Select the Database Name. We created our table in PegaData database so select that in drop down.



Provide table name that we created using Database tool.


Save the rule and do test connectivity.



In test connectivity we can see the class is successfully mapped to Newly created table.

Lets create a case in Purchase request class and check whether the created case is displaying in that table or not.

Created flow.


Run Flow.



When run the case a error message displaying. It shows that key is missing . We have to provide key for PurchaseRequest Class.



Provide key in PurchaseRequest class definition and save the rule.



Now issue resolved and a case created.



Lets check the Instance in Table.



We can see the newly created instance in PurchaseRequest table.

Ping in Comment if you have any doubt😊

No comments:

Post a Comment