Pega Report Definition Guide
Pega Report Definition Guide
Introduction
In this post, we will see in detail about report definition rule, how to create a new RD
and its usage.
I love the term ‘Data’. Every business process requires some data. Think of any
organization – bank, finance. They collect the data and use the data for their
business processes.
Every BPM application requires some data for processing.
They need the customer data, product data, vendor data, courier
transportation data etc.
They store these data in some database (Oracle, MySQL, Postgres, etc) and
use the data when required.
Now how can Amazon application talk with the database. They need some language
right?!
Any application can talk with the database using Structured Query Language (SQL)
Pega stores the permanent data in database tables and temporary data in memory.
So Pega talk to the database using SQL. There is a rule type Connect-SQL to support
this.
Important note: Report definitions can only be used to browse the record from the
database table. It cannot be used to alter / update / delete the records.
A report definition rule generates SQL query to retrieve data from the
database tables and can generate HTML to display the results.
Reports definition supports chart and can be used in dashboard reports.
Report definition can retrieve data from two or more tables.
Report definition supports parameter and can be rendered dynamically.
Let’s see how we can achieve the same using report definition rule 🙂
We know that all concrete classes in Pega are mapped to database tables. We
need to check which instances we need to browse and from which table.
Here, we need to browse the Sales class instances, Let’s open the class and check to
what table it points to?
Here in this demo, I am going to report on all the sales cases in the application. So
my applies to class is ‘PKS-MyKnowPega-Work-Sales’
a) Query tab
b) Chart tab
c) Report Viewer
d) Data Access
e) Parameters
In this block, you can specify an array of columns you need to fetch from the
database table and can also decide the presentation for each column.
a) Use single value property – You can either use optimized or un-optimized
columns ( affects performance)
b) Use calculation builder to use a function template and format the column value.
I will make a short post on, how to create a SQL function and use one 🙂
You get all three sales cases from the database table.
The other 3 columns in the ‘Edit Column’ block, determines the UI representation of
the results.
Page |4
a) Summarize
This list varies based on the property type. Obviously for the property pyID of type
‘text’, we don’t need the Sum and Average summarization 🙂
We will see in later about the differences between List reports and summary reports.
b) Sort type – It can be blank, Lowest to highest (ascending) and Highest to lowest
(descending).
c) Sort Order – With in the sort type you can determine the priority of sort order. It
can be 1-N.
Imagine I am fetching the country and state in the search results. I gave
country as Sort order 1 and State as sort order 2.
You can see in the below picture, sorting is first applied to country and then within
the country sorting is applied for states.
You got a Settings icon on each row. Let’s check it. There are few additional options
available.
Column width – You can determine the Column width in px or % ( dropdown option)
Column format – You can determine presentation of the column values.
Filtering option –
You get an option to display values across columns. Now you know, how to include
the columns and format the results.
Condition – you can specify the condition logic label. If there are more than one
condition in where clause, then you can differentiate them using labels.
Caption – Description on the filter condition displayed in the report viewer. We will
see more in detail later in this post.
Column source – You can specify the column name on which you are going to apply
the filter condition. You can also use calculation builder to use some functions.
Relationship –
a) You can either hardcode the value or get the parameterised value dynamically.
b) Select Value – You can click on the link to select the available values ( Internal
query executed to get all the data).
This list all the available pyID values for the sales instances. You can select one.
c) Calculation builder – you can also make use of the function to render the
calculated values.
d) Other Filter Options.
When you run a data transform, you get a window to display the results.
Page |6
a) Allow any changes – Default, we can update both the column and
its values
b) Allow changes to value only – We can update only the column values
c) Read only, allow no change – We cannot update the filter conditions
d) Field not visible in Viewer – Filter section is not visible
We will test
Imagine we have a where condition where the value is passed dynamically. Say the
filter condition is pyID=Param.pyID
If Use Null if empty – True – then the where condition will be .pyID=””
If Use Null if empty – False – then the entire where condition is ignored.
Ignore Case – You can also ignore the case ( case sensitive or not) for the values.
If you have more than one filter rows, then you can use the logical operators to
satisfy the requirement.
Update: for a summary report, you get an option to use filter condition after
aggregation
Run the report, you can see the caption in the filter conditions.
Allow caption to left side of condition – You can allow the caption to only left side of
condition.
Like FirstCase=S-1
You can see in the below picture that S-1 & S-3 contains same customer name and
phone number.
Step 1: Add only customername and phonenumber as select columns. For testing
remove all the filter conditions
Ranking –
You can rank the results and filter and display only few results.
o You can either select Top ranked (highest value) or bottom ranked (lowest
value).
o You can specify the number of rows to retrieve.
You can use either OverAll – To use all the search results in ranking; For Each
Group – Ranking within the group
Scenario – Here I need to fetch and display recently created Sales case.
My ranking criteria will be Top ranked = Highest values = maximum created date
Page |8
You can see it returned the recently created sales case S-3 🙂
Scenario – You need to fetch and display the operators who are getting the highest
salary in their department ( Sales, Service)
You can enable ‘For each group’ Also you need to do some configuration in Report
viewer tab.
Check group results and decide what are the columns can be group headings.
In the above picture, I selected 1 – 1, So the sort order = 1 column will be the column
heading.
You can see ranking is done based on the phone number grouping.
S-1 and S-3 have same phone number, but the highest ranked case is S-3
(recently created) J
Chart tab, Report Viewer – We will see more in detail in separate post.
Data access
I am making a separate post on Class Joins, Declarative Index Joins, Associations, Sub
reports.
Maximum elapsed time in seconds – You can specify the maximum number of
seconds, the report is allowed to run. If does not return the results in the specified
time, then the run is interrupted.
Maximum number of rows for export – Specify the maximum number of rows to
export.
Maximum elapsed time in seconds for export – You can specify the maximum
number of seconds the export process is allowed to run.
On selecting this option, I can fetch all the descendant class instances too.
Include all descendant classes – this is default select and include all instances
irrespective of layering.
Use alternate database – You can use an alternate database table to report on.
Note: Alternate database table details are specified in the database table instance
P a g e | 10
On selecting this option, the row key (pzInskey) will be default added in the select
columns.
Security –
You can specify a privilege rule. The operators with the specified privilege can only
run the report!
Parameters tab
Introducing parameters can support reusability. At run time we can pass different
values to the parameter and get the result.
Step 2: In the Query tab – filter conditions add the Parameter value as condition
value.
You can see the results. You can pass this parameter dynamically at run time.
1. After the report definition rule is run, You can check a page
‘pyReportContentPage’ in the clipboard.
You can also see the pxResults pagelist to see the results content.
Introduction
In the previous post, we saw a simple example to fetch the data from a single table.
However there may be situations, where we need data from more than one table.
In SQL, you might have come across the terms – INNER join, Left OUTER Join,
Right OUTER Join.
In facebook, you know a term ‘Friend of a Friend’. A friend of friend can see
some private details this, that!!Here you need some common friend, to view
few details.
Like the same, if you need details from 2 tables, then you need some common
column – This is where the join takes place 🙂
Here, you can see Country code is a friend of friend to both the tables.
I need to fetch 4 columns – StateID, State Name, Country Code (States table)
and Country Name (Countries table)
It takes out rows which are common(intersection) in both the tables by Country
Code. Leaving out Country code 04 and 05
Left Outer Join – Includes all the rows in the left table and uses only data from the
right table.
You can see all 5 entries are in the results table. Right tables are just used to get the
data.
Right Outer Join – Includes all the rows in the right table and use only data in the left
table.
Requirement – I got a requirement to display the sales details and the assignment
details.
Here I need to join two tables – Work table and Assign-Worklist table.
Here pzInsKey in work table and pxRefObjectKey in worklist table, both points to
case Key and can be considered friend of friend. You can join using those columns
Type –
b) Include all rows in this class (Applies to class) – Left outer join
Edit conditions –
You can add one or more rows as filtering conditions. Prefix A is used to identify the
joined class columns.
Note: You can also add more than one class joins in a report definition rule.
Step 3: Go to Query tab and add the A.pxAssignedOperatorID column
You can see all rows are included from the Sales class with data only copied
from the joined class.
There are no entries for S-1 and S-3, so no Operator ID.
You can see all rows (2) in the joined class are included and the other columns are
just filled from the left table.
Declarative index joins is similar to class join with the exception that instead of class
name, we specify declare index name J
Associations
It is very simple. If you find, you join two class instances frequently in report
definition, you can create an association rule.
Association rule explicitly defines the Join condition between two classes.
Pega provides many standard association rules. You can also create one.
Step 6: run the report and check the Inner JOIN results.
Sub reports
Requirement – I have a simple requirement, to get the list of operators who don’t
have any assignments ( Assign-Worklist) entry.
My design choice is
P a g e | 16
Step 2: run the report definition and check the operators list.
Step 3: Create another report definition rule in Assign-Worklist class (sub report)
Step 4: run the report definition to get the list of operators who have assignment in
their worklist.
Note: This is the ideal candidate to use remove duplicate rows option.
Step 5: Now go to ‘GetOperatorsList’ report definition and add the sub report.
You can select number of rows returned from the sub report – More than 1 row
You can specify filter conditions for the sub report results.
You have an addition type option – Do not match rows.
Note: If you don’t use any join condition, you can choose – Do not match rows (I
choose this)
P a g e | 17
Ignore filter conditions in sub report – We can also ignore the filter condition in sub
reports.
You can specify some local names for sub report columns.
You can also specify the parameters for the sub reports. If you use the same
parameter value in both reports, you can check the Auto-populate option.
My Name is gone 🙂
Please follow the below link to know more about when and how to use sub reports.
https://pdn.pega.com/when-and-how-use-sub-reports-report-definition-reports
Introduction
In this post we will see the types of reports and then the capabilities in report viewer
and report editor
To know about Class joins, Declare index joins, Associations and Sub reports, please
visit the below link
Report Definition – Class join, Declare Index join, Associations and Sub
reports
1. List Reports
2. Summary reports.
List report can be converted to a summary report by updating the summarize column
in Query tab.
Summary report supports Charts. Charts serve to display the report results in
pictorial representation.
Once you enabled summarize column in any row, you get the chart tab
enabled for selection.
You can select a chart type from different types available. I selected bar type
You also have some option to set legend and glider option.
P a g e | 20
You can drag and drop the columns in the drop zone.
You can also drop customer name column over the chart.
Report Viewer
Report viewer is the window which displays the report result, when you run it.
The configuration of report viewer is set in the report definition rule – Report viewer
tab
Report header
Do not scroll header – You can freeze the header, when the results are large and
involves vertical scrolling
Step 1: Pega provides a sample section that is used to filter the results based on
range.
P a g e | 21
Display custom section inline – displays the filter section inline in report viewer. It
not checked, it is visible in the modal dialog on click on filter section.
Report body
Display actual data while editing report – While in report editor, you can see
the actual data
Display rows in custom section – You can display rows in a custom section
Grouping –
You can see the records are grouped based on work status (Sort order 1)
User actions – These configurations determine what are the actions, user can
perform on the report viewer.
Enable actions – determine what are the options to be available in the Other actions
option.
Enable smart info – if required, you can show some additional information on each
row.
Note: You make use of an activity that accepts pzInskey as parameter and returns the
section content.
Report Editor
By default developer and manager role have the required privilege to edit
report from the report browser.
You can drag and drop the property either in the filtering area or results grid.
Click on the column heading menu. You can take action on the column
heading
Let me how you a small demo, how to add a new column – pxCreateDateTime
Step 1: From the data explorer, select the pxCreateDateTime and drag and drop to a
new column.
You can see a new row is added with the function we selected:)
Introduction
In this post, we will see more in details about how to create reports and
personalize from user portal.
Business users can themselves create reports from the user portal. Obviously
at back end, report definition rules are created.
To create a new rule, you need values for some configuration points.
Take report definition as example, what are the major configuration points
required to create a new report definition rule?
1. Report name
2. Report class
3. Reporting ruleset
4. Columns to include (format)
5. Filter conditions
Filling the template is always easy for any business people. Job done.
You get the recent reports column in the work area and categories in the right
panel.
1. Add report
2. Add category.
Once you complete your changes. You can publish your report from
private to public category.You can also directly publish it to public
category.
So, here I am creating a new public category. Click on Add category and
specify the category name and type.
Click submit. You can see a new public category with 0 reports.
Pega creates a new rule under category rule type J. We will see more in detail
later in this post.
Here multiple users can update the rule at the same time without any
lock.
Note: Usually you update the users access group who can create reports in
production
Step 3: When you save the instance, you may get this error.
This is because, you need to specify the reporting ruleset in the product
rulesets array in the access group form.
All perquisites are set :). Let’s continue creating the new report.
a) Case type –
Here, I am choosing Case type – Sales & Report type – List. Click submit
Hope you know, how to add columns and filter using report editor.
You can also visit the below link for more details.
Report Definition – List reports, summary reports, Report viewer, Report editor
Step 7: I am removing all the filters and adding case ID & Customer name as
the display columns.
You can see Pega created a new private category ‘My Reports’.
I am going to save the report under private category.
Click on the private category. You can see the report ‘Sales Case details’.
What are the actions you can perform on reports and categories?
a) On Categories
Click on the settings icon near the categories. You can edit the category
name.
b) On Reports
Task Scheduling – You have few options to schedule the report delivery (
time and error hadling).
Task Output Processing – You can attach the report in PDF or excel. You
can select the operators you need to send notification. You can either attach it
in the email or send a link to download.
You also have an option to configure notification message. Click on the button.
P a g e | 29
You get fields to enter the email subject and message. Click submit.
1. Category
2. Shortcut
3. Report definition
Now you open the same report from user portal. Click on edit report
and remove the pylabel column.
Save the report. Now come to designer studio, and refresh the report
definition.
You can see the pyLabel column removed automatically. So the changes
you do from the portal will get reflected in that report definition.
Note: You can also perform the vice versa. Updating the report definition
rule directly, can reflect the changes when viewed from the user portal.
Category – There are 2 new categories created. One private category and one
public category.
Step 1: Use any manager operator ID and uncheck the Allow rule checkout
option.
Note: Also make sure the manager access group is specified with reporting
ruleset.
You can see Owner type ‘A’ shared and Owner as Managers access group
🙂
You can also create a new category – Records -> Reports -> Category
P a g e | 31
Shortcut
You can also create a new short cut rule via Records ->Reports -> short cut
1. You can see those instances by navigating Designer studio -> Reporting
-> Components -> Scheduled Tasks
You can also click on the task name to see the contents. Case id is PX-
ST-3
You can click and open the instance and get the pzInsKey.
b) Queue instance
You can open the class ‘System-Queue-ScheduledTask’ and get the queue
items.
You can open the instance and get the pzInsKey. The same can be deployed to
higher environments.
We are at the end of Reporting 🙂 Hope you liked my 50th post !!+
Introduction
In this post, we will see how to schedule and subscribe any reports from
Pega.
Business scenario
Say Amazon is using pega application for the sales department. The sales
department has different line managers for different sales category. For
example, Sales manager for electronics department, sales manager for
household department etc. As a Sales manager, daily they need to generate a
report on the total sales. The report should list all the sales cases that contain
the sales details like product name, amount etc.
Let’s assume, that sales manager uses the Pega manager portal.
Solution 1: The Sales manager is provided with a sales report in the default
Report tab. So, with this report, Sales manager can view the sales case any
point of time in the day. He/she can also alter the filter criteria to look at the
report for any data range. This is the power of pega in reporting. The reports
in the report browser are provided with an interactive UI that can be easily
handled by the business users for custom reports.
Solution 2: Any report in Pega can be scheduled to any users. So, the above
the sales report, created in the reports tab can be scheduled to run daily by
11.59 AM and the report PDF can be send to the sales manager.
1. A working email account – make sure you have a working email account.
How to configure an email account & send outbound email from Pega?
I just updated the default email account with a valid email address.
Always check the agent schedule instance, since it is a data instance and can
be different (updated manually) from the agent rule instance.
Note: If node classification is enabled, then check the agent schedule created
for backgroundProcessing node.
Note: Look and feel of the reports may vary based on your UI Kit version.
Step 3: Click on New report and select the right case type in the pop-up.
Remembering the requirement, I need to list all the sales that happened in
one day.
The solution is to run the report at 11.59 to list all the cases that were created
today.
Step 5: Enter a meaningful report name and for now place it under your
private category.
a) Task definition
b) Task scheduling
c) Task output processing
Task definition
Task name & Task description – Both are prefilled by default. If you need you
can always change the values.
Task scheduling
You can specify the Time at which the report to be scheduled. We have a
limitation here that it runs at round-off hours like 1 AM, 2 AM etc.
In our requirement, we planned to schedule by 11.59 PM, but now with this
limitation we need to run it on 12 AM and update the create date filter to
yesterday. So that at 12 AM, the start of the new day, it generates the report
for the previous day.
One-Time only. Here you can specify the exact date on which it should
run.
Recurring task. For this you get some additional fields to fill in.
For example – for daily, you can specify either to run on weekdays or on all
days; Please switch and check the possible options.
Start date – you can specify a date from which the scheduling should occur
P a g e | 37
Note: for testing, please update to the next hour to see the email, which we
will obviously do at the end.😉
One error, retry – On selecting this option, you can do some error handling if
the report fails.
Output file format – You can specify either PDF or Excel report.
Send notification to the following users – As I mentioned before, you can see
my name is auto subscribed. You can also add other users for subscription.
They will be auto subscribed.
The email ID configured in the operator rule form will used as the To address
for report. So make sure the email address is properly updated in the operator
ID.
P a g e | 38
Attachment – We can either attach the report file with the email or send a link
for them to download.
Configure notification message – Click on the button and you can configure
the email message.
Click on submit.
Now the real fun part 😊 Let’s see the Pega architecture for the report
scheduling.
First thing that comes to your mind is – scheduling part should be handled by
agents in Pega, right?! We will see it.
Step 2: You will see there are three child classes for the scheduled task.
Step 3: You see the instance we created just now! Click and open the
instance to verify the details.
Step 4: If you are interested more, then you can look at the flow and case
type corresponding to the scheduledtask case.
Note: most of the rules are in available mode and hence can be customized.
But make sure you customize only the extension points so that you don’t
make the new features in the later releases 😉.
If you delete the report, then corresponding scheduled task instance will be
cleared. Please test this on your own.
You can also, click and open the instance to check the
minimumdatetimeforprocessing value.
Step 1: Update the scheduled task instance to the next one hour.
As soon as you update the time, the scheduled queue instance gets updated
with the right process time.
Step 3: Let the agent pick and process the queue item. You will see once the
agent picks up and process it successfully, attempts made will be 1 and the
process on data will be the next day 9 PM.
Now this report scheduling is successfully tested. Now the next step, how to
promote the report scheduling to higher environments?
Usually the reports will be created in the lower environment and promoted to
the higher environments. Simlarly two more instances has to be manually
promoted to the higher environment for supporting report schedule
Note: To promote any instance manually, you need to include the pzInsKey in
the product rule.
Now you may get a question, if more than one people subscribed to this
report, will it be same in all environments. The answer is yes. All those details
stay within the case data.
We are at the end of this post. Let’s see a summary of report scheduling
Hope you enjoyed this post on report scheduling. Look out for a business use
case in your project and try to implement the same 😊. See you all in my next
post. Take care.
P a g e | 42
87
Introduction
In this post we will see in details about Agent and Agent Schedule in Pega.
You can code it like ‘providing a button and by clicking on that, we send an
email containing the status report’. But if you do like this people will laugh at
you.
Here comes the Internal background process to provide solution for this
requirement.
http://myknowpega.com/2017/05/13/requestor-types/
1. Schedule
2. Security
3. Nodes
Schedule tab:
a) Scheduled agents
Pattern – Periodic/Recurring/Startup.
Periodic scenario: Imagine you need to update a work item every one
hour. In the interval field, you specify the seconds as 3600.
Recurring scenario: You need to send mail daily at 1 pm. Use Interval
field advanced option, to set the time daily to 1 pm.
Startup: Only when the server starts ( not used often).
Max Records – Shows how many records the agent should process before
going to sleep. Usually applicable for standard agents.
Imagine a scenario where you need to update a work item in the background
based on SLA.
The agent activity tries to acquire the lock for the work item, but is already
locked by other agent. Now basically the agent activity cannot update the
work item (fails). In this scenario, if
AQM is checked, then the agent re-queue the item for later processing.
If not checked, then the agent gets only one chance to process it and do
not persist the queue item.
Enable this agent – True / False. Enable the Overall agent rule.
Interval – Default interval seconds. Used when if we don’t provide the Interval
for Individual agent activity configurations.
Security tab:
Access Group – Applicable only for Advanced agents. Used to identify the
agent activity rule.
P a g e | 45
Access group -> Application -> Builds ruleset list -> Agent activity rule.
Nodes Tab:
We know Pega system can run on different nodes using different servers.
This tab lists the nodes, where the agent schedules are created. We will
discuss about Agent schedule later in this post.
Requirement: Route the Leave request case to manager queue for approval.
If the manager didn’t approve the next day, the send an Email to him.
Even after 3 days if he didn’t approve, then Auto-approve the request.
As part of development, we just configure an SLA and don’t mind how the
background SLA works.
I am going to take you to a trip and explain in detail how the background SLA
process works.
SLA process:
To know the basic of SLA, please visit my exclusive post on Service level
agreement.
http://myknowpega.com/2017/05/17/service-level-agreement/
Front end:
P a g e | 46
When the Leave request case reaches the assignment shape Assign-
.AddAssign gets called.
Back end:
Agent – Pega-ProCom
The agent activity runs and starts processing the queued Goal event. Use
activity ExecuteSLA to set the Urgencies and execute the escalation activities.
It Re-queues the entry again for Deadline event.
The agent activity runs and starts processing the queued Deadline event. Use
ExecuteSLA to set the Urgencies and execute the escalation activities. Here
no passed deadline, so no more queue entries are added again. Leave is
auto approved after deadline.
All the transaction items need to be carried out in agent activity. We can
configure the activity to re-queue if some error occurs.
1. Standard agent uses the access group of the user who queues the
entry, while the advanced agent uses the access group specified in
Agent rule or requestor type.
2. Standard agent supports AQM, while advanced agent do not.
3. Standard agent wake and run only when there are queue entries with
available lock, while the advanced agent runs even if there are no
queue entries. This is because advance agent is responsible for agent
queue processing.
Imagine the same scenario discussed above. You need to configure an agent
to update a work item. Now you configured the agent as Advanced agent and
made it available in 3 nodes. Here, Object contention occurs, since advanced
agent activity should handle the locks. If the same is configured using
Standard agent, then there won’t be any locking issue.
Here you can see the relation between agent and agent schedule in
pega.
As we discussed before Agents can run in multi nodes.
Imagine a scenario where you need to update agent run Interval from
300 seconds to 30 seconds in particular node. To solve this Agent
schedule comes in Handy.
Use SMA.
In the Agent management, you can check if the agent is running or not.
If there is some error and the agent has stopped, then you can see the
stack trace or log files.
Stop -> start -> Delay -> go the requestor management and trace.
Explanation:
Hope you get the basics about agent and agent schedule in Pega
P a g e | 49