What Is an Activity in Pega?
An activity is a rule that automates a process through a sequence of steps that run one after another. We use it when no other rule type fits the requirement. When all the steps finish, control returns to the rule that called the activity.
Use an activity only when no other rule type can do the job. Pega recommends using standard out-of-the-box (OOTB) activities and avoiding custom activities wherever possible.
Best Practices for Pega Activities
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
When Not to Use an Activity
Activities are flexible, but they are harder to read, test and maintain than purpose-built rules. Before writing one, check whether a simpler rule does the job:
- Setting property values: use a Data Transform.
- Making a decision or evaluating a condition: use a When rule, Decision Table or Decision Tree.
- Loading data for a screen: use a Data Page.
- Querying records: use a Report Definition.
Keep an activity for cases where the logic really needs sequential steps that these rules cannot express.
Activity Step Settings: Label, Loop, Conditions and Methods
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 is 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 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.











Extraordinary Article.
ReplyDeleteCan please a next post on Parse XMl and XML stream
Sure thing.
Deletegood information
ReplyDeletegood information keep it up
ReplyDeleteeasily understandable......thank you
ReplyDelete