Thursday, 12 July 2018

Call a Pega Activity from Java

Sometime we may need to call a pega activity programmatically instead of declaratively. So using Java we can call a pega activity. 
We need to follow these steps in order to call the activity from java:-

1. Create a map of parameter name-value pair  :-

 HashStringMap  parameters = new HashStringMap();

parameters .putString(“pxObjClass”, “Rule-Obj-Activity”);
parameters .putString(“pyClassName”, <class_name>);
parameters .putString(“pyActivityName”, “<activity_name>” );


2. Use pega public API tools to call activity:-
tools provide many public API methods. we will use doActivity.

tools.doActivity(parameters , workpage, tools.getParameterPage() );



Sunday, 8 July 2018

Some Important Pega PRPC database tables

Following are some general pega rules database tables which are used to store different objects :-

pc_assign_worklist:
 
It is used to store worklist related assignments

pc_assign_workbasket:

Work basket related assignments are stored in this table.

pc_work:


It is a default table in pega to store work objects. This behavior can be customized to use a user defined table to store work objects.
Steps to follow for customization:-
1. Copy the pc_work table schema  and modify the table name
2. Change the class group mapping (Data-Admin-DB-Table) to the newly created table.

pc_data_workattach:

Store work objects attachments i.e. files, screenshots etc.

pc_history_work:

It is used to store work objects history.

pr_data:

Default table for data instances.
 
 
pr_operators:

Store the Data-Admin-Operator-ID instances
 

p.s.:- All the PegaRULES database tables have two very important common columns, pxObjClass and pzInskey

pzInsKey:

pzInsKey is called the handle for an instance because it is a unique column for each instance which store the key with exact modified date.

pxObjClass:

The pxObjClass column, present in every table, identifies the Process Commander class of the row. When committing an instance of a concrete class to the PegaRULES database, the system uses the pattern inheritance algorithm to find the table name.

Reference: Pega Community

Difference between Page-Validate and Property-Validate methods in Pega Activity

Page-Validate and Property-Validate are some of the mostly used methods in Pega activity. Here is the difference in both the methods:-

Page-validate:
Page-Validate method is used on a page property to validate all the embedded properties which are present on a page. If a page has embedded pages i.e. Page-List, this method works recursively to validate all the properties for each Page. This method consumes a lot of system resources and takes more time. If you want to validate specific properties use Obj-Validate method with a Rule-Obj-Validate rule.


Property-Validate:
Use the Property-Validate method in an activity to ensure that a property value meets certain requirements including:

1. Property value should be non-null   (Select the required check box in the method)
2. Perform Rule-Edit-Validate rule on a property

A property-validate method is used to impose restrictions on a property value. We can validate multiple properties using Property-Validate method.

Saturday, 30 June 2018

List of some useful OOTB Pega PRPC functions

Here I will provide the list of some useful functions based on the data types.

Date/DateTime functions:-

addTime(DateTime,calender) from PegaRULES:DateTime library
 
Add an amount of business or calendar time to a DateTime



CurrentDateTime() from PegaRULES:DateTime library

Return the system current DateTime in following format: 20181026T051021.606 GMT


differenceBetweenDate(DateTIme1, DateTIme2, usebusinessdays, Calendarname ) from Pega-RULES:BusinessCalendar library


Calculates the integer number of calendar or business days between a first and a second DateTime value, optionally based on a calendar data instance. This is positive if the first date is later than the second date. A day is defined as 60*60*24 seconds in this calculation.



FormatDateTime(DateTime, format,*,*) from Pega-RULES:DateTime library


For example FormatDateTime(DateTime,"yyyy-MM-dd'T'HH:mm:ss",null,null)



isBusinessDay(date,calendar) from Pega-RULES:BusinessDate library


True if the date is a business day in the calendar identified by the second parameter.


Property Functions:-

IsInPageList(LookFor, LookAt, LookIn) from Pega-RULES:Utilities library 
Searches through the values in a Page List property for a match.  


IsInPropertyList(LookFor, LookIn) from Pega-RULES:Utilities library

Search through the values in a Value List property for a match.

PageExists(pagename, activityname) from  Pega-RULES:Default library

Check whether a page of a specific name already exists, in the context of an activity.

Data Elements in Pega

Pega PRPC handles data through different data elements. As part of our implementation, we create a data model to represent and store different information. The fundamental unit of data model in pega is called "Property". 

There are different property modes in pega for our convenience. For example if we want to store a single piece of information like Name then we use Single Value Property and for a collection of information like Address we use Page. Here is the list of property modes:-

Single Value:- Use to store a single Text , number or Date e.g. "Pega",1234.

Value List:- Use to store ordered list of values e.g. For job history of employee we can use value list to store Job(1)='App Dev', Job(2)='Pega Dev' etc.

Value Group:- Use to store unordered list(like key value pair). e.g. Phone(Home)='1234', Phone(Office)='2345' .

Page :- To store multiple embedded properties e.g. Address Page with properties HouseNo, PinCode, City etc.

PageList:- To store ordered list of pages  e.g. Address(1), Address(2). 

PageGroup:- To store unordered list of pages e.g. Address(Home), Address(Office).

There are also some advanced property type like Java Objects(String,Integer, Class Object) or List of Java Objects.



Create a new application in Pega

Normally in programming languages it takes a lot of time to create a new applications from scratch but in pega we have a wizard to create a new application. So in few clicks we can create a brand new pega application skeleton.
Steps:-
After logging in open the new application wizard in web based pega IDE. Click PegaRULES icon from top toolbar and select "New Application".







There are the following details you have to provide as part of this wizard:-

Basic Information:- Application Name, Description, Org etc.

Business Objectives:- what this application will be used for..

Define Cases:- Here you can provide multiple cases

Define Data:- Provide the data information which will be used to interact with the application

Here you can select  either Implementation only or Framework only or both based on your requirement.
Implementation Only:- Application will created on the top of PegaRULES or the Framework you select.

Framework Only:- It will a create a framework application which can be used to build other application on the top of it.






 
And after providing all the details for each screen you can submit and an application will be created.


Monday, 21 May 2018

Pass/Propagate data from a parent case to child case

Sometime in a case management application where we have one or more subcases for a case, we may need to use some data from a parent case in a child case. e.g. In a 'Request Purchase' case we have one Purchase Order subcase where in the subcase we may need OrderId or PurchaseId from the case. This is called 'Data Propagation'. 
To propagate the data from a case to subcase we need to configure the data propagation on the parent case. The data propagation configuration is available on Details tab of a parent case. Click edit to configure data propagation.
Here we have two options to map the data:-
a. Directly map properties of parent case to the properties of child case
b. Use a data transform

Normally we map the properties but if you need some conditional mapping or more advanced data propagation then you go with data transform. 

Important:- Data Propagation only happens once i.e. when cases are initially created. If you propagate a property from the Parent case to a child case, and the property value later changes on the Parent Case, the property on the child case does not get updated.