Press "Enter" to skip to content

Dynamic referencing and dynamic class referencing (DCR) in Pega

49

Introduction

In this post we will see about dynamic referencing and dynamic class referencing in Pega.

Pega –  build for change

What is build for change?!

When I start to think of a nice example, I see a  TV before me.

  • It has HDMI port,
  • USB port,
  • A port for cable connection,
  • A port for dish connection,
  • Cables to connect DVD player or to use Playstation ( FIFA 18 😀 )

I can reuse the TV in multiple ways!! . I call it as built for change.

Re usability and build for change are interchangeable.

Now let’s come to our Pega, Whenever you start building an Pega application, always have this is mind – Build for change.

Build it for future changes. Figure out all the configuration points and make it dynamic.

What is Dynamic referencing?

Dynamically reference values in the application. I will walk you with an example

  • A Pega application supports Sales and Service cases in an organization.
  • Both the case contains an approval process.
  • All the steps in the approval process are same, except that the case has to be routed to either SalesWB or ServiceWB.

I give you two approaches to decide which is the best

Approach 1:  Create 2 separate approval process for Sales and Service

Sales – Route it to Sales WB

Service – Route it to Service WB

Approach 2: Create a single approval flow in the parent layer ( Ideally we create in framework layer )

and dynamically pass the Approval WB Name

The reasons, why Approach 2 is best?

  • In future, the same approval process can be applied for other cases with the change in Workbasket name. Say there is a new case – ‘Marketing’ and the approval should routed to ‘’MarketingWB”. Here you can use the same flow by dynamically varying the workbasket name.
  • Lesser number of rules and easy to maintain.

Now, how to set the workbasket name dynamically?! – We will see about in details shortly.

What is dynamic class referencing?

Dynamically refer the classes – also called ‘DCR

Why do we use DCR?

  • When you are in Framework layer and you want to make use of Implementation layer classes.

For example, You have an activity in framework layer.  You want to open a case from that activity. We  use Obj-Open method to open the case.

When you try using an Implementation class, you will end with the error

<Class name> does not exist or is not a valid entry for this ruleset and its prerequisites.

Note: You can also create a Implementation work type from Framework layer by making use of DCR.

These are the ideal use cases for DCR.

  • Never hardcode the class values in activities or other rules.

This is because, Every application should adapt to changes.

Say for example, You have any existing class and want to rename. So if you have hard coded the class name, then the developer has to scratch his head to find all the referencing rules.

If you use DCR here, then you can change the class name at once place and if reflects in all the referencing rules.

How to configure DCR in an application?

There are two things you have to identify.

a) Where to store the  dynamically referenced variables?

b) Where to use these dynamically referenced variables in the application?

We will go one by one.

How to store the values dynamically? – This is how we implement DCR

There are 4 rule types, we need to make use of.

a) Data layer ( This can be in organizational or framework level)

b) Properties – Holds the dynamically referenced values.

c) Data Page – Load the variables

d) Data transform – Source for the data page. ( This can also be replaced by activity for complex computation)

Here I  am going to show, how we can extend our application for dynamic referencing.

Step 1: Create a new data class extending framework.

I name it as “AppExtension”.

Step 2: Create  properties

A Page property –  holds all the dynamically referenced values – AppExtension

  • I created this property in ‘Work’ class and can be reused in all work cases.
  • I used ‘Refer to a data page’, because this may change based on the application we are in.

We will see very shortly, how this same property loads different data based on different application.

 Single value properties in data class –  First let me create an property to hold Purchase Order class.

Step 3: Create a new data transform to set the value.

First, you can have an data transform in framework layer.

You can also create a ruleset specialized version  in the implementation application, and override these values from framework.

Note: When you need some complex business logic, you can make use of activity in place of data transform.

Step 4: Create a new data page.

I named it as “D_AppExtension”

Data page definition will be

Structure – Page. This is going to be a single page structure

Object Type – Refer the AppExtension data class

Edit mode – Read Only. No need to edit the values

Scope – Thread. Since we are extending this on application level.

Note: In some scenario, you may need to extend the Organization level configuration points. Eg – Org Int end point URLs. I such scenario, You can make of the data page throughout the organization. Scope can be node/requestor level.

Data Source – Use data transform and specify the newly created data transform name.

Now all our rules are ready

Whenever you create a data page, It’s always nice to run and test the data page.

Let’s check it. Run the data page from Other actions.

  • You can see the PurchaseOrderClass is populated from the data page.

Now we have successfully configured DCR in our application.

We will see, How we can make use of DCR functionality in application

Step 1: Open any activity in Framework layer. (I am using the same activity, I used in Introduction part)

Step 2: In the Obj-Open step, replace the Open class hard coded value with the dynamically referred AppExtension.PurchaseOrderClass value.

  • Now, You can save the activity and at run time the class name is passed dynamically.

Note: Data pages are used to render the values dynamically at runtime, when required.

What are the places, we commonly use Dynamic referencing?

The below examples are just a piece out of a cake.

a) In a flow shape, where we can refer values dynamically – Worklist or Workbasket.

You can also find other shapes, which can accept the dynamically referenced values.

b) Connectors – End point URL

Remember, Connector end point URLs tend to change based on the environment. We may have the actual URL only in production system. In the lower environments, we may have different URLs for Dev / QA.

Integration connectors can be used across organization. I recommend you to create a separate Organization data layer. You can create the below rules.

1. Organization Int class – BBB-Int-EnvSettings.

2. Create separate properties for separate URLs you use ( page property not required).

For example, In your application you can have multiple connectors for multiple functionalities. You can create individual properties to hold the URL values – FetchPolicyURL.

3. Create a node / requestor level data page – D_EnvSettings

4. Create either Dynamic system settings or System settings to hold the URL values.

My next post will be on System settings and DSS 🙂

5. Create a data transform to set the values from DSS to URL properties.

Now you can refer the fetch policy details URL dynamically loaded from the data page.

Note: Please follow the same steps, how we configured before

D_EnvSettings.FetchPolicyURL – contains the URL value

  • You can see an Equal to sign (=) before referring the resource path.

This is because, resource field always expects an constant value (Inbuilt Pega code). It may interpret the values you provide as a constant, unless you provide an equal sign before.

A simple trick is, whenever you see drop down select value field, you can directly refer without equal sign. This can be identified by a blue triangle at the right bottom.

If you don’t see this blue triangle in any input field, then

  • You can use any constant values or
  • You may be forced to use an equal sign before you refer any value dynamically.

c)  Activity steps – Obj methods.

Apart from these places, You can refer the values dynamically in many places in the application.

What are the points to remember?

  • It’s always nice to have 2 data pages to hold the dynamically referenced values

D_AppExtension – Application related values

D_EnvSettings – Environment related values ( URLS )

  • Try maximizing the reusability features by incorporating the DCR functionality.
  • Using DCR, you can initiate Implementation work types from framework layer.
  • You can always extend the framework by copying the data page source data transform to application specific rulesets.
  • Try to bring all the classes and Organization specific rules like – Workbasket, Workgroup inside the data page. This can be extensively used to route work dynamically.

We are at the end of this post :).

I will try to make posts frequently. See ya soon in my next post.

 

 

  1. Suresh Suresh

    It’s so good , thanks for posting with good example .

    – Many thanks
    Suresh

    • Premkumar G Premkumar G

      Thank you so much, Suresh and you are most welcome. 🙂

  2. Ramesh Ramesh

    Hi Prem,

    What do you mean by Ruleset Specialized version. what is the use of it can you please explain it .

    Thanks
    Ramesh

  3. Arshad Pasha Mohammed Arshad Pasha Mohammed

    Clear explanation.

    Keep up the good work bro.

    • Premkumar G Premkumar G

      Thank you so much for your appreciation, Arshad Pasha Mohammed. 🙂

  4. Teja Teja

    Hi PremKumar

    This is a very good article on DCR. I have query ,it would be really help full if you can answer this.

    The scope for the Data page D_AppExtension has been set to Thread, but what is the need for setting it to Thread level instead of Requestor. As per my understanding a single requestor cannot access multiple applications at the same time, so what is the exact purpose of setting the scope to Thread in this scenario.

    Regards
    Teja

  5. udhay udhay

    Nice explanation….

    • Premkumar G Premkumar G

      Thank you, Udhay. 🙂

  6. swapna swapna

    Prem your way of explanation is excellent. Please can u post latest interview questions and answers with explanation. They are asking scenario based questions . Can u help in how to answer those questions?

  7. Prasu Raya Prasu Raya

    Hi Prem,

    Thank You for sharing this topic.

    • Premkumar G Premkumar G

      Hi Prasu Raya,

      You are most welcome. 🙂

  8. Somnath Panda Somnath Panda

    too late.. but thanks a lot for this great post. It very much required in almost all the pega project.

    • Premkumar G Premkumar G

      I’m sorry for the delay. You are welcome, Somnath. 🙂

  9. Sairam Sairam

    Hi Prem
    Great explanation good work.

    Thanks.

    • Premkumar G Premkumar G

      Hi Sairam,

      Thank you so much. 🙂

  10. ashok ashok

    can you plz expalne” performence analaysis” in pega
    and deployment in pega
    and can you spent time on functionalities of SMA

  11. N ROSS N ROSS

    Hi Premkumar, in the above example of using DCR to supply a URL endpoint to the application – surely it would be much simpler to store the endpoint in a DSS rule and reference the DSS directly from the activity? This approach allows for different endpoint data (per environment) to be stored in the DSS rule, avoiding hardcoding of endpoints in each environment?

    • Premkumar G Premkumar G

      Exactly Nigel Ross :). That is what I planned for my post on ‘System Settings and DSS’

  12. Vamsi Vamsi

    Hi Prem,
    You are doing a wonderful work here –
    CAn you throw some light why D_AppExtension page why it should be in the thread level instead of Node level.

  13. mahesh mahesh

    Hi Prem,

    i am waiting for next post .

    • Premkumar G Premkumar G

      Hi Mahesh,

      I will post soon. Stay tuned. 🙂

  14. Pradeep Pradeep

    Waiting is over for this post.
    Great work..!!

    Thank you.

    • Premkumar G Premkumar G

      Thank you and you are welcome, Pradeep. 🙂

  15. Ashok Ashok

    Hi Prem, Could you please post Connect-MQ & Service-MQ and also OAuth2 mechanism.

    Thanks, Ashok

    • Premkumar G Premkumar G

      Hi Ashok,
      Yeah I’ll post about them. Stay tuned. 🙂
      Regards,
      Premkumar G

  16. Tejaswi Tejaswi

    Thank you so much for the explanation…..I’m so happy to find your tutorials..they are so clear…I’m new to pega….can you please share how to get started with pega and master it I want to write CSA certification….once again thank you for the tutorial..

  17. Venkat Venkat

    Hi Premkumar,
    I can’t hold myself from appreciating you. You are doing such a hard work to share knowledge that you had, Great Work!!! Appreciated!!! I have a question though, I faced a interview question like, there is FW layer and also implementation layer in a application and requirement is to pull implementation work object details using report definition.But the restriction here is you should create report definition only in FW but not in implementation. How can we acheive that. Need ur help.

  18. Beginner Beginner

    Hi Prem,
    Detailed and Great ease of explanation on DCR a thumps up!

    Can you help me how to implement DCR in below requirement.(pls tolerate my over intelligence questions or silly questions as I have more theoretical exposure and little practical pega development exp, kindly help it wold be greatful)

    1.Have a “rolemodelFWFlow” Defined in FW with two assignments -1st assignment routed to “currentoperator” , 2nd assignment routed to “WorkQueue”[workQueue in 2nd assignment should be configurable].

    2. Need Two Applications with Flows namely “App1.FollowerFlow1” and “App2.FollowerFlow1” with same steps as “rolemodelFWFlow” defined in FW but the 2nd assignment need to be routed to supplied App1.WB1 and App2.WB1 for respective application Flows App1 and App2.

    Qstns:
    1a.Do we need to define two separate flows in two applications App1.FollowerFlow1 and App2.FollowerFlow1 and call “rolemodelFWFlow” while passing the relevant work queues – App1.WB1 and App2.WB1 for respective application Flows from App1 and App2.?

    or

    1b.launch the “rolemodelFWFlow” while passing the relevant work queues – App1.WB1 and App2.WB1 for respective application Flows from App1 and App2.?

    2.
    If approach 1a is suggested then we need to duplicate same flow in three different places which is defeating the idea of reusability!!

    Or

    If 1b is suggested – If each application (App1 and App2) users are different and they are tied with (App1 built on FW) and (App2 built on FW) will they need to switch to the FW application to create the case?

    3. Request you to suggest a correct step by step implementation.

  19. Laasya Laasya

    Hi Prem,

    Can I use DCR in report definition filter, where I have to include two values for pxObjClass?

    Something like below
    pxObjClass = .AppExtension(“page1”).property1 , .AppExtension(“page2”).property1

  20. shaik azmathulla shaik azmathulla

    Good explanation with example. Thank you for this post 🙂

    • Premkumar G Premkumar G

      Thank you and you are welcome, Shaik. 🙂

  21. Acharya Acharya

    HI Prem, it really nice explanation . i need to know the Scopes thread/node/requestor

    more detail with simple example

    thanks

    • Premkumar G Premkumar G

      Dear Acharya,
      Thank you for your appreciation. 🙂
      I’ll post about the topics you mentioned soon. Stay tuned. 🙂

      Regards,
      Premkumar G

  22. Divya Divya

    Great work Prem.. I’m amazed at the quality and in depth knowledge you share here.. I can see the culmination of hours of Pdn read and practical experience at one place.. Thanks a lot for helping us.

    • Premkumar G Premkumar G

      Thank you for your warm appreciation, Divya. 🙂
      I’m happy to hear that you are finding my blog useful. 🙂
      Stay tuned for more new posts.
      You are most welcome. 🙂

  23. Pratik Pratik

    Nice work, please notify me whenever you post a new article.

  24. Syed Basha Syed Basha

    Good topic with example.

  25. Avik Avik

    Very nicely explained buddy! thanks! 🙂

  26. Sravanthi Sravanthi

    Hi Prem,

    Thanks for your post.

    Could you please let me know whether we can create work objects on the framework class.

  27. Vivian Richard Vivian Richard

    Fantastic Explanation. It would be better if you could actually demonstrate this in a youtube video.

  28. Ranganath Ranganath

    Super explanation Prem. I always feel that your blog is lot more helpful than PDN.☺️

    Is this concept of DCR new in Pega 7.x versions or it exists on earlier versions as well?

    Congratulations on completing 1 yr of your blog.

    • Premkumar G Premkumar G

      DCR idea was introduced in Pega 7, but you can use the concept in Pega 6 versions also.
      Note: Few places may not support property referencing ( we may need to hardcode values)

  29. Piyush Piyush

    Hi Prem, I have a question related to using Dynamic class reference. Say I imported an xsd in class MyOrg-Int-MyXsd class. If I need to use a page of this class in an acitvity, and I declare a page in the pages and classes of this activity, then how can I utilize the DCR there? Every time the xsd updates I need to change class references everywhere.

  30. Snehasis Snehasis

    Hi Prem,

    Thanks for posting,its really helpful. I have one question can you explain how to implement DCR in case of agents(in agents rule). How to avoid hard coding of class name for scheduled agents?

  31. Chiru Chiru

    Your posts are very clear to understand.

    • Premkumar G Premkumar G

      Thank you, Chiru. 🙂

  32. Swetha Swetha

    Hi Prem
    Thank you very much for your posts. It is very helpful for beginners like me.
    I have a question , Can we use the same method for calling an activity in implementation later from an activity in framework layer?

  33. Ishwariya Ishwariya

    Very nice explanation…

  34. Ashiq Ashiq

    Very Good Explanation.

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!