You are here: Reference > Rule types > Activities > Creating an activity

Creating an activity

Before creating a new activity, it is recommended that you investigate model driven alternatives that can deliver the desired results. Alternatives such as data transforms, declarative rules, and features of flows and case management can remove the need to create a new activity.

  1. Create an activity by selecting Activity from the Technical category.

    Field

    Description

    Apply to

    Select the class to which this activity applies. If your activity is to be referenced in a flow, identify a work type (the Work- class or a class derived from the Work- base class).

    The list of available class names depends on the ruleset you select. Each class can restrict applying rules to an explicit set of rulesets as specified on the Advanced tab of the class form.

    Identifier

    Enter a name for this activity, starting with a letter and containing only letters, numbers, and hyphens. Choose a name that is unique within the Apply to class. The name must be a valid Java identifier; see How to enter a Java identifier.

    The length of the class name plus the length of the Identifier cannot exceed 128 bytes.

    Template

    Select a template activity name to automatically set the activity type (and in some cases add pre-populated steps to the form):

    • Route — Sets the Activity Type and adds three Property-Set steps.
    • Locate — Sets the Activity Type.
    • Trigger — Sets the Activity Type.
    • Utility — Sets the Activity Type and a Property-Set step.
  2. Define input parameters for the activity.

    Select In or Out to indicate whether the parameter is used for input to the called activity or output from the activity.

    The system does not prevent setting the value of an In parameter. A called activity can access and change both In and Out parameters on the parameter page.

  3. Add steps to the activity.

  4. Select Actions > Preview or type the equivalent keyboard shortcut CTRL+ALT+P to see a step-by-step verbalization or English text description of this activity (informally known as the "Describe This Rule" presentation). The system creates an HTML topic describing each step of the activity, with links to other rules referenced by the step.

  5. Click Save.

  6. If your activity contains Java steps, run the Rule Security Analyzer before locking a ruleset version, to look for possible security issues.

The standard function callActivity() in the Pega-RULES Utilities library calls an activity, but returns only void, not a value result. You can execute an activity in an expression, but only for its side effects. Identify the primary page, the activity, and the parameter page. For example:

@Pega-RULES:Utilities.callActivity(pyWorkPage,
       MyActivity, tools.getParameterPage());

To learn how to invoke callActivity() indirectly (as an extension) in a custom mobile app, see also callActivity action as extension.