Pega Activities complete understanding

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

There is no option than an 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

Let's talk about Methods inactivity:

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

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

A loop repeats step a specified number of times. Loops iterate over the elements of a value list, value group, or page group, or page list.
The precondition (When) or reprocessing action - When the condition is evaluated before the step runs. Based on the result either the step is skipped or performed.
Postcondition (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 that describes the action system that 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. parameter name.
Local variables are referenced as Local. variable name.


Parameters make activities more reusable by allowing them 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 the parameter page which is not visible on the clipboard, but we can see in the tracer.

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

We can see parameters in the Parameter page and local variable on the variable page in tracer at run time. 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, the step page is page memory. Each activity will be executed in the context of the called activity or rule. For example, an activity called from a 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 screenshot in the step-2 step page as "tempWorkPage" means step-2 will be running on the "tempWorkPage" context to close the particular case or work object. Step page must be defined in the "Pages & classes" tab of the activity rule form and should assign the appropriate class.

Calling other activities from one activity:
Activities can call other activities for re-usability and 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 the process finished control goes back to the calling activity.
Branch: Pega runs the called activity when the process finished control goes back to the rule that is 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 the 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 the 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 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 method.


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.


4 comments: