Sunday 16 September 2018

Activities


The Pega platform provides rules to model almost any type of application behavior. An activity rule is used to describe the logic for an automated procedure. In this lesson, you learn about activity rules, and how activities automate certain types of system actions. You also learn how to use the contents of Pega's activity library  and how to avoid writing custom activities in Pega applications.



An Activity is an automated procedure, structured as a series of steps that execute in sequence.
Activities are the primary procedural processing rules in Pega.
Each step can perform an action, transfer control to another activity, or execute custom Java code.
 
Methods
A Method is an operation that is performed by a step of an activity.
A method contains a predefined set of basic operations that perform computations, update properties and other aspects of the clipboard, or move data between memory and the database. Some common methods are:
  Property-Set — Set the value of one or more properties.
  Page-New — Create a page on the clipboard.
  Page-Remove — Delete a page from the clipboard.
  Apply-Data-Transform — Update property values based on a data transform.
  Call— Call another activity.

Activity Execution
By default, an activity executes its steps in sequence.
Control the flow of execution by repeating a group of steps, defining a set of preconditions for a step, or jumping to a later step.
Each step of an activity contains multiple parts:
Non-action items such as Label, Description, and Step Page.
Action items such as Loop, When, Method, and Jump to indicate an action or condition for an action.

Activity process step control options include following:
Label provides an identifier for the step that can be referenced from other steps.
Loop provides an iteration through the elements of a Value List, Page List, Value Group, or Page Group, and performs the provided activity method on each value or each embedded page.
When defines a precondition that controls whether the step is executed or skipped.
Method indicates which method or activity the step will execute.
Step Page identifies a page to be used as the context for referenced properties within the step.
Description is text explaining the action that the step is performing
Jump condition or post-condition defines how this step transitions, or jumps, to a later step.




This sample activity executes four steps to send emails.

Step 1 executes another activity with the Call method.
Step 2 executes some Java code to check if the email is a broadcast.
Step 3 loops through a page group and creates emails for matching targets.
Step 4 executes the Page-Remove method to clean up clipboard pages.

Page Context of Activity Execution
During execution, an activity can access data from three pages:
Primary page is a clipboard page which has the same class as the Applies To class of the activity and is designated when the activity is called. This page provides data context for the whole activity.
Step page provides data context during the execution of this step. If a step page is not specified for a step, the primary page becomes the step page.
Parameter page contains parameter names and values, as listed in the parameters tab. An activity can access incoming parameters and update outgoing parameters, as a way of communicating information with other rules.


Activity Parameters
Parameters allow the execution of an activity to vary at run time, which promotes reuse.
Parameters can:
Be accepted as inputs.
Be used to convey results.
Serve as both inputs and outputs.
Activity parameters are listed in the Parameters tab of the Activity form.
If a parameter is an input to the activity, access the value received from the calling activity.
If a parameter is an output of the activity, set values using the Property-Set method.


API Activities
Predefined activities that perform standard functions.
Prior to creating any new activities, explore the API activities to see if one exists that can meet your requirements.
Some of the commonly used API activities include:
CorrNew for creating and sending emails
AddWork for creating a new case instance
UpdateStatus for setting the status of a case instance
Invoke API activities from a flow shape or a flow action. To invoke an API activity from a custom activity rule, use the Call method from an activity step.

Process API Rules
The Process API is a group of standard activities you can use to start and advance work flows without implementing user forms.
To see a list of the Process API rules, select Designer Studio > Process & Rules > Processes > APIs. Expand each row to learn more about each activity.

Activities Best Practices
Write activities only when none of the API activities are appropriate for your requirement. 
Whenever possible, use alternatives that are easier to understand and maintain.
For data manipulation, use a data transform instead of activities.
For data calculation, use a declare expression instead of activities.
For queries from an database, use a report definition instead of activities.

Load disqus comments

0 comments