Linked Properties in Pega
In this blog article, we will talk about the Linked property configuration and its usage.
What is a linked property?
Linked property is a single-value property that can act as a linking pin between any two instances.
In Pega we have different instances like work and data instances under different concrete classes.
Let’s say you have a ClaimsRequest case instance. During the different stages in the case lifecycle, the claims case needs to access and use the details from the operator instance that created the claims case.
Cases get stored into a separate table, say work table and operators are saved into the pr_operators table as Data-Admin-Operator-ID class.
So, what are the ways to access the operator instance from the case instance?
a) You can use a data page, that accepts the operator ID as input and does a lookup on pr_operators table to populate all the details. You can specify it as thread level and use it in the case lifecycle. This looks a better choice since we load it when needed using data page and can be used across places.
b) You can also use an activity to obj-open or obj-open-by-handle the operator instance in a user page and use the details from it. This can be the least preferred solution and you know why :P. Using activities and loading it in user pages every time when needed is not a good practice
You can also define and use linked property to access the operator details. Linked property loads the operator details when referred.
A single value property from the claims case can make a link to the key value of an operator Instance.
Do you recognize any of the database concepts?
Foreign key. Foreign keys inthe database help to make a link between two tables.
You can read more about it in the following link –
SQL FOREIGN KEY (w3schools.com)
Instead of using foreign key SQL query to make link between tables, Pega uses the properties (key property) to make a link between two instances ( two tables)
How we can create and use the linked property?
As a pre-requisite for this tutorial, I have already defined the claims case type.
Step 1: Create a new property – CreatedBy in the claims case layer.
Records -> Data Model -> Property -> Create New
Step 2: Mark the property as Linked.
In the property form general tab, mark the data access to automatic reference to the class instance.
Step 3: Specify the linked class and mapping.
In our requirement, we need to make a link to the operator instance. Operator instances are stored under class Data-Admin-Operator-ID and so that will be my linked class.
As soon as you specify the linked Class, Pega automatically does the link mapping between the source property and the Linked class key. Pega always makes the job easy.
We know the key of the operator Instance, it is pyUserIdentifer.
Using the Class form or the class group form you can find the keys for the concrete classes.
Since the Operator class has a single key defined and so no problem in direct one-on-one mapping, what about making the link with classes having multiple key properties?
Just change the linked class to any of the Index classes.
Note: All Index classes should have the three default keys – pxInsIndexedKey, pxIndexCount, pxIndexPurpose.
You will get the option to map the linked class keys to any of the source properties.
So, no problem. We can easily map the source property values so that the link can be made.
Okay, now let’s revert back and use the data-admin-operator-ID class and save the property form.
Now that we have successfully created a linked property.
How to make use of the Linked property?
It is very simple. You can reference all the linked instance properties using a simple reference
.<LinkedProperty>.<LinkedClassProperties>
For example – .CreatedBy.pyWorkGroupName, will give the workgroup name that is assigned to the linked Operator.
Let’s test it.
Step 1: Update the current operator pyReporting manager to administrator@pega.com.
Step 2: In the pyDefault data transform, initialize the CreatedBy property and access the reporting manager.
Step 2.1: Intialize the CreatedBy property to pxcreateoperator which holds the case creator name.
Now at run time. CreatedBy value will be the operator who creates the case, It will be my name.
Step 2.2: Map the reporting manager into the claims case.
I am mapping property pyName as .CreatedBy.pyReportTo
You can already see the context is data-admin-operator-ID.
Save the data transform.
Step 3: Trace the case creation.
Start your tracer and enable the linked pages settings.
Create a new case.
In the tracer at pyDefault data transform, you see Linked page Miss hit – because the Linked page is not found.
And so, an SQL query is made to open the data-admin-operator-ID instance using the key.
Step 4: Check the Linked page from the clipboard.
In the clipboard, you have a separate category of pages called Linked Pages.
But, you don’t find any linked pages here!!!
Why??
The answer is that linked pages are read-only and so it stays in the clipboard until a commit operation is made.
Because after a commit operation, there are some chances that data may get changed in the database and so Linked pages are cleared. In the next reference, the Linked page will be created again making database query again to get the recent data!!!
If you want to see the Linked page in the clipboard, just run the data transform manually by hardcoding the createdby value.
Now run it. In the clipboard, you can find the linked page 😊
How Pega use the Linked properties?
OOTB pyAccessGroup property in the Operators class is defined as the Linked property that can link to the access group data instance.
Before ending this article, let’s talk about some practicality!!
1. Linked properties can improve the performance by loading the instance details if you are using lower pega versions. Just understand there is no magic in linked properties, it also makes a query to the database to retrieve the results. The only advantage can be, instead of going with activities you can prefer the Linked page/properties for data access.
2. But with Data pages, you can do the same data access in a much more effective way than linked pages. The linked page always loads the entire instance details in the clipboard every time the referenced
Always do remember, Linked pages will be cleared on every commit so it needs to load again and again for every reference – meant SQL query will be made again and again ☹
The only advantage I could think of is easy reference to linked class instance without additional page creations.
Data pages Vs Linked Pages, data pages win 100/100 battles!!
In my last 9 years of experience, I have used Linked properties in only one of the projects when it was in Pega 6 version.