Featured post

GetNextWork functionality in pega

What is GetNextWork in pega? Pega provided a functionality to get the most urgent assignment(task) for user to work on. This is configured o...

Pega Activities complete understanding

To automate the process when there are no appropriate rule types available we can use activities. Activities contains sequential steps runs one after other. Once all steps completed control goes back to the rule that called activity.

There is no option than activity to use at particular situation pega suggesting to use standard activities (OOTB - Our of the Box) and avoid writing custom activities.
Best practices:
1. Limit activity steps to fewer than 25.
2. Use alternative rules whenever possible like data transform to set property values.
3. Limit writing Java code

Lets talk about Methods in activity:

Label - Unique identifier for step give one or two characters to identify the step. Other steps can reference this step on their JUMP/transition conditions. To comment the step give //  (two slashes) so that particular step will not be executed. If loop step is commented all child steps excluded from execution. 

Loop - to repeat the step multiple times select repeat values from loop drop down.

A loop repeats step a specified number of times. Loops iterate over the elements of a value list,value group, or page group or pgae list.
Precondition (When) or reprocessing action - When condition is evaluated before the step runs. Based on the result either the step is skipped or performed.
Post condition (JUMP) or post processing action - a condition s evaluated after the step runs. Based on the result either activity jumps to an alternative step or ends.

Methods - Each step should specify a method which describes the action system is going to perform on the step. Example Property-Set, Obj-Open

Property-Set  sets the value for a specific property where Obj-Open opens an object onto the step page. Find more on activity methods here Activity methods
Parameters and Local variables:
Each method will accept one or more parameters ad local variables, what is the difference between parameters and local variables.
Values stored in parameter values can be shared between two activities but the scope of local variables is confined to the activity in which they are declared.
Parameters can be referenced as Param.parametername.
Local variables are referenced as Local.variablename.

Parameters make activities more reusable by allowing to pass arguments when the activity is called, rather than upfront during development.
activity parameters are defined on the Parameters tab on the activity rule form.
Syntax to reference parameter value param.<ParamName>, parameter names and values will be stored on parameter page which is not visible on the clipboard, but we can see in the tracer.

We can declare parameters and local variable in Parameters tab of the activity rule.

We can see parameters in Parameter page and local variable on variable page in tracer at run time. In order to see local variables values in tracer we need to select ""Local variable" check box.

Parameters on "Parameters Page Name" =unnamed= page and local variables on "Local Variables" on "view variables" .

Step page:
Each step will be executed on the step page, step page is page memory. Each activity will be executed on the context of the called activity or rule. For example an activity called from an utility shape to update case status will have context as the page assigned to the case type (pyWorkPage).
 Step page will set a different context to the step. For example, see the below screen shot in step-2 step page is "tempWorkPage" means step-2 will be running on "tempWorkPage" context to close particular case or work object. Step page must be defined in "Pages & classes" tab of activity rule form and should assign appropriate class.

Calling other activities from one activity:
Activities can call other activities for re-usability and to use standard peg activities. Pega provides two methods to call other activities "Call" and "Branch".
Both call and Branch specifies the current activity to find and run another activity.
Call: Pega runs the called activity when process finished control goes back to the calling activity.
Branch: Pega runs the called activity when process finished control goes back to the rule that called the first activity. Original calling activity ends.

For example Call scenario: Main activity Work-Cover-.reopenWorkObject is calling from the flow "Utility" shape on pyWorkPage. 
reopenWorkObject  is calling another activity which is in Work-.acquireWorkObject. When acquireWorkObject completes the process control goes back to main activity that is Work-Cover-.reopenWorkObject.

For example Branch scenario: Main activity Work-Cover-.reopenWorkObject is calling from the flow "Utility" shape on pyWorkPage. 
reopenWorkObject  is calling another activity using Branch which is in Work-.ActionAddQuestion. When acquireWorkObject completes the process control goes back to the main flow where main activity Work-Cover-.reopenWorkObject called. Control doesn't return to Work-Cover-.reopenWorkObject activity and it ends this activity.

Security in Activity:
we can restrict users not to run this activity and can specify the activity type.

Allow direct invocation from the client or a service - check box: to run the activity from the user input or through a URL, for example we can select this box for service activity or if this called by an AJAX event, at run time if this box is not checked and activity is being sued by URl or ajax form pega returns an error called Fail:Security because check box is not selected. For most activities this will be checked as the activities called from another activity  through a call or branch methods.

Require authentication to run Select to require that only authenticated requestors can start this activity. Clear to allow guest users to run this activity, if they meet other  security and access criteria.