Please go through our previous post to understand the configuration & usage of the data page rule in Pega.
Many a time we may need to fetch data from multiple sources and consolidate them before we can use them. For example, online food delivery applications like Swiggy/Zomato connects with multiple data sources to fetch the restaurant details, food – its available quantity & price before loading the information in the application.
What is Aggregated Sources?
- It is one of the data source option available in the Data Page rule starting from v8.4
- It can be used to consolidate data from multiple sources and populate them onto a single page which can be readily used by the application.
Why Aggregated Sources?
Let us consider that OSP has a Claims application where list of Customers and list of Prospects/leads are maintained in two different tables and we have a requirement to fetch a consolidated list of all the customers and prospects.
How do we achieve this? 💭
- We can create a data page sourced with a data transform.
- Data transform can first call a report definition to get the list of Customers, loop through the list, and append the list to
Data Page.pxResults()
. - Data transform can then call another report definition to get the list of Prospects, loop through the list, and append the list to
Data Page.pxResults()
.
Wouldn’t it be easier if Pega itself provides us a way to configure multiple sources within a data page directly instead of using a data transform or activity to call multiple sources? Yes, Pega provides this option in the form of Data Page with Aggregated Sources.
How to configure Aggregated Sources?
- Aggregated sources is applicable for both List and Page structure data page.
- The data source option in the data page should be selected as Aggregate Sources .
- Give a name to the aggregated source and configure sources using Add source option. The system executes the sources in the order they are listed.
- Source can be selected from anyone of the available sources.
- It is mandatory to configure Response Data Transform even if Object Type and class of the Source is same.
- When a data page with aggregate source is executed, it runs the configured sources in the mentioned order and updates the data page with each of its results.
Let’s discuss few business scenarios to understand the real-time usage of the aggregated sources
Business Scenario 1
Let us consider the above-mentioned scenario where OSP has a Claims application with the list of Customers and list of Prospects/leads maintained in two different tables and we have a requirement to fetch a consolidated list of all the customers and prospects.
Implementation
- Just for POC purpose, Customer and Prospect information are maintained as data type in Pega.
- Create a data page of type List and select Source as Aggregated Sources.
- Let us configure an aggregated source referencing 2 report definitions to fetch Customer and Prospect List.
- Let us also configure Response Data Transform and add them to each source.
Execution
Let us save and run the data page. We can see that the data page runs both the report definitions in the configured order and displays the consolidated results.
Business scenario 2
Let us consider that OSP Claims application has a requirement to display the following details for a particular customer ID:
- Customer Details like Customer Name and Address for a particular customer ID which is maintained in a data table.
- Customer’s reward points which are present in an external application called OSP Customer Rewards. OSP Customer Rewards has exposed a REST service that accepts Customer ID as an input and returns the reward points of the customer as a response.
- Based on the reward points, the Customer needs to be classified as Silver, Gold, or Platinum. Customer Type should also be displayed along with Customer Reward Points.
Implementation
- Create a data page with Page Structure with Customer ID as a parameter to the Data Page.
- Let us select the source as Aggregated Sources and give an Aggregate Source Name.
- The first requirement is to get all the Customer Data from a table. We can use a look-up and pass the Customer ID so that we get all the Customer Data maintained for a particular Customer ID as part of the data base table. We need to configure Response Data Transform for an aggregated source data page even when Object Type and source class are the same.
- The second requirement is to get the Customer Reward point by invoking a Connector exposed as part of OSP Rewards application. Let us click on +Add Source to add the next source. We can use a Connector as source to satisfy this requirement. Customer ID is passed as the request using Request Data Transform and Customer Reward Points obtained as response is mapped using Response Data Transform.
- The third requirement is to classify the customer as Silver, Gold or Platinum based on the Reward Points obtained from external system. To incorporate this, let us add another source and invoke a data transform. This Data Transform will call a decision table which returns Customer Type based on the Customer Reward Points that is obtained as response.
- Now we just have one data page with aggregated sources (Lookup + Connector + Data Transform) that populates all the required information in one hit.
Execution
Let us run the Data Page by passing Customer ID PCX001 as the parameter and observe the results.
We got all the desired values in a single data page. 😊
Advantages of Aggregated Source
In real time scenario, if there is a need to consolidate data from multiple Connect REST sources, this option will be really helpful. Without this option, we will need to write an activity to call multiple Connect REST and consolidate the results.
Pointers to Remember
- Aggregated Sources is available as a Data Page source option from Pega version 8.4 and above.
- It can be used with both List and Page structure.
- It can be used to consolidate data from multiple sources and populate them onto a single reference page.
- Sources get executed in the order they are configured.
- It is mandatory to configure Response Data Transform even if the Object Type and a class of the Source are the same.
- We can use multiple combinations of Aggregated Source within a single data page using the If and Otherwise capability provided by the Data Page.
We are now at the end of the post. We hope you got the understanding of when and how to use Aggregated Sources as a Data Page source.
We are glad to publish the article requested by @ Aditya Kunal on “Configuring Aggregated Sources in Data Page”. If you want us to publish any articles of your choice, please fill out this form & we will make sure it gets published.
Thanks guys for this article. I will go through and share my comments guys.
Thanks Kunal bhaai for making me reach here. This site is extremely good and this article very easy to get concept. And because of this I was easily implement aggregated data page in my project and got expected result. Thanks osp team.
Clap clap 👏👏!!!! Very well written guys. I loved the in depth coverage guys. What a way to start the Osp Trivia 3 article. Great job guys. Thanks for prioritising my request.
Thank you so much @Aditya Kunal
Happy Learning from OSP 😊
Nice article. Good to see new feature article in the blog. Good job team.
Thank you so much @Sanketh
Happy Learning from OSP 😊
Nice thanks
Happy Learning from OSP 😊
Wow guys. Next article is property qualifier?? Am excited guys, thanks again!!!
Great explanation team.
Happy Learning from OSP 😊
Easy to understand. Thank You Team.. 🙂
Thank you so much@Sathya Srinivasan
Happy Learning from OSP 😊
Great explanation OSP!!
Dear OSP Team,
I am Nishant Kumar Aggarwal. I happened to visit Aditya Kunal Joshi and he pointed me to this article on aggregated data page. We wanted to implement this in our project. Explanation is so well written that it is really very easy to understand and implement. This looks like a great guide to Pega Developers. Keep up the good work.
This blog has now become like one stop page for anything related to data pages guys. Soon expecting u will become that for everything in pega guys. Nice!!!
When can we expect article on property qualifier?
Any update??
in the response, data transform you are using “DataSource” is that keyword holds all data of the table, you are updating page ryt?
@Vinod bro. They have called lookup with primary key as Param to fetch entire pk row. This pega keeps in a page called ‘DataSource’. That page is copied to primary page which in this context will be D_ page with aggregated source so that the actual D_ page gets copy of the data source. Bro please confirm if this is what you are looking for.
Yes. that’s the default page which maintains the results when your Data page context class and source class differs.
Nice article. Thanks for focussing on new features.
Thank you so much @Raviteja
Happy Learning from OSP 🙂
Very well written article. You have so well explained that it looks like you have peeled the banana and kept. Fresher like me also able to get the concept so much easier.
Thank you so much @shoba
Happy Learning from OSP 🙂
Hi osp team I am Prakash. Kunal is my teammate who referred me to this blog. This article is very nice and we went through this as a team to implement in our project. Super article and keep up this good work.
Thank you team for a great article. And spl mention to Kunal for helping me with this article link.
Excellent article team. Keep up the good work.
Hey Shreejeeth bro and puspakumari sis. Welcome to this wonderful blog. Kunal referred you both?
Excellent article
Thanks Kunal for requesting this article and thanks for providing link to me for this blog
U r welcome Supraja sissy
How can we set the response data transform
Hi Team ,
As per above example we have 3 sources for data page, what if any one of the source fails ?
will data page load the results with the two sources(which executed successfully ) or will it fails ?
Thank you so much for this article.
One doubt in business scenario 2:
Used 3 sources–> Lookup, Connector and Data transform
Suppose connector failed to get the response from external system what will happen?
will the 3rd source(data transform) get executed (or) it stops executing the DataPage?
I just want to know, what will happen when the connector fails??