Skip to main content

Creating an activity

Pega Community logo

Note: The following content, referenced from Pega Community, is included here to help you better achieve the module learning objectives.

Automate a system task for which a more appropriate rule type is not available by creating an activity. With activities, you define a sequential set of instructions, or steps, that the activity completes automatically. Each step calls a method or supported rule type to perform the required processing.

Consider a scenario in which an insurance company must submit insurance claims to the Registry of Motor Vehicles. To minimize the impact on users, you can configure an activity to automate claim uploads so that your application submits insurance claims outside of peak hours, without user intervention.
Before you begin: As a best practice, before creating an activity, investigate model-driven alternatives that can deliver the desired results. Alternatives such as data transforms, collections, declarative rules, and features of flows and case management can remove the need to create new activities. If possible, use the standard activities that Pega Platform includes. To view a list of all standard activities, flows, and flow actions that you can use in case management, in the header of Dev Studio, click Configure Case Management Processes APIs . Create a custom activity only if the standard activities cannot fulfill your business needs.

To promote modularity, limit each activity to fifteen or fewer steps and focus the activity on completing one task.

  1. In the header of Dev Studio, click Create Technical Activity .

  2. In the Activity Record Configuration section, in the Label field, enter a name that describes the purpose of the activity and helps identify the activity.

    Start activity names with a verb that indicates the purpose of the activity. Follow the verb with a noun or noun phrase that indicates an element on which the activity operates. Capitalize the first letter of each word in the name of the activity.

    For example: Name your activity CreateClassPage or GetHTMLFilePath to clearly convey the purpose.
  3. Optional:

    To change the identifier that other rules use to reference this activity, in the Identifier section, click Edit, and then enter a name that is unique within the Apply to class.

    Choose a name that starts with a letter and contains only letters, numbers, and hyphens. The name must be a valid Java identifier. The length of the class name plus the length of the identifier cannot exceed 128 characters.

  4. Optional:

    To automatically set the activity type and, in some cases, add prepopulated steps to the form, click View additional configuration options, and then select one of the available activity templates:

    • To create a route activity that you can use in an assignment shape to route an assignment to a worklist or work queue by using custom routing criteria, select Template for Route type activity for worklist. For more information, see Assignment shapes in flows.
    • To create a trigger activity that you can use in a Declare Trigger rule to set the values of parameters, select Template for Trigger type activity. For more information, see Creating Declare Trigger rules.
    • To create a utility activity that you can use to automate the processing of a case, select Template for Utility type activity. For more information, see Calling an activity or an automation from a flow.
  5. In the Context section, define the context in which to execute the rule:

    1. In the list of built-on applications, select an application layer for the activity.

    2. In the Apply to field, enter a class that you want to associate with the activity.

      At run time, the activity runs in the context of a page. The class that you specify in the Apply to field must be either the class of that page or in the class hierarchy of that page's class. For more information, see Understanding class hierarchy and inheritance.

      The list of available class names depends on the application context that you select.

    3. In the Add to ruleset list, select a ruleset and a ruleset version in which you want to store the activity.

  6. Optional:

    To override the default work item that your application associates with this development change, press the Down arrow key in the Work item to associate field, and then select a work item.

    For more information about your default work item, see Setting your current work item.

  7. Click Create and open.

  8. Before populating any steps, on the Security tab, select an appropriate activity type to determine whether and how other rules can reference this activity.

    For more information, see Security tab on the Activity form.

  9. Optional:

    If you want to skip the step or use a when condition that references this step, on the Steps tab, complete the Label field.

    • To skip the step, enter only //.

      An excluded loop step excludes all child steps from execution.

    • To allow other steps to reference this step in their When or Jump criteria, enter a short string.
  10. Optional:

    To repeat a step or a contiguous sequence of steps a number of times, click Loop, and then define a loop.

    The most common way to loop is to iterate over a Page List property, such as pxResults, by using the For each embedded page option. For more information, see Repeating steps in an activity.

  11. Optional:

    To complete a step only if a set of parameters fulfill conditions that you define, click When, and then define the preconditions for the step.

    For more information, see Activity form - Completing the Steps tab - Entering preconditions.

  12. In the Method field, press the Down arrow key, and then select a method or instruction that you want to complete.

    For example: To retrieve a list of data instances that fulfill a specific set of parameters, enter Obj-Browse. To set the value of a specified property, enter Property-Set.
  13. Optional:

    To set a context for the step that is different than the primary page of the activity, specify the name of the page or property that you want to use as the context.

    For example: To copy a specific order from a list of previous orders in memory, set the step page to the appropriate page in the page list of results.

    By default, an activity executes within the context that calls it. For example, an activity that a utility shape calls during case processing executes against pyWorkPage, which is the page that is assigned to the case type. Complete the following steps only if you want to change the default context:

    1. On the Pages & Classes tab, add the page or property that you want the system to use at run time.

      For more information, see Defining the pages and classes of a rule.

    2. In the Step Page field, enter the name of the property that you want the step to use as context.

      Depending on the scenario, you can use additional syntax. For example, if you selected the For each embedded page loop in step 10, you must enter a full property reference to a Page List property, such as pagename.pxResults.

  14. Click Expand to see method parameters.

  15. In the Method Parameters section, configure how your application applies the method or instruction that you selected in step 12:

    • If you selected a method, enter parameters specific to that method.

      For example, if you selected the Obj-Browse method, in the PageName field, enter the name of the page on which you want to store the results, and then in the ObjClass field, enter the name of the class that you want the method to browse.

    • If you selected an instruction, such as Call, Branch, Collect, or Queue, enter parameters specific to the rule that is associated with the instruction.
    • If you selected Java, in the Java Source field, enter Java source code that you want the activity to execute.
    Note: At run time, the system passes the values that you specify to the method or instruction. The system holds the parameter names for a step on a special clipboard page called the parameter page, which is visible while tracing, but not with the Clipboard tool.
  16. Optional:

    To specify conditions to evaluate after the method in a step runs, but before the activity moves to the next step, click the Jump link, and then define a transition.

    For more information, see Defining step transitions in an activity.

  17. Click Save.

  18. If your activity contains Java steps, ensure that the activity causes no security issues by running the Rule Security Analyzer tool before locking a ruleset version.

    For more information, see Searching for security vulnerabilities in rules.

  19. To configure another step in the activity, click Add a step, and then repeat steps 9 through 18.

Note: Define input parameters for the activity. For more information, see Defining the input parameters of a rule.

When you define the input parameters, select In or Out to indicate whether the parameter is used for input to the called activity, or output from the activity. Using input parameters can make activities easier to understand, call, and test.

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

  • Activity form - Completing the Steps tab - Entering Method parameters

    The Method Parameters section allows you to pass information from an activity to a method or instruction specified in the Method field of a step.

  • Activity form - Completing the Steps tab - Entering preconditions

    Use the When button to define a when precondition that conditionally skips execution of a step. The system evaluates whether specified conditions are met before it executes the method or instruction referenced in the step. If false, the rest of the step is skipped.

  • Defining step transitions in an activity

    Use the blue Jump button to open a pop-up dialog, and identify transitions, optional fields that can end iteration, terminate the activity, or cause control to jump to a later (higher-numbered) labeled step. Use transitions to specify conditions that are evaluated after the method in the step is performed, but before the execution continues with other steps.

  • Repeating steps in an activity

    Use the Loop button to identify iterations, optional fields that can define an enumeration of or loop condition for this step.

  • Calling an automation from an activity

    Call an automation from an activity without using a Java step.

  • Best practices for writing activities for background jobs

    Ensure that work items are processed correctly and that data is not corrupted during a node shutdown by using best practices for writing activities for background jobs.

  • Security tab on the Activity form

    Use the Security tab to specify the activity type and optionally to restrict which users (or other requestors) can execute the activity. This optional security supplants restrictions based on RuleSet and version.

  • Defining the local variables for an activity

    Use the Local Variables section to create scalar variables.

  • Activity form - how to create activities for flows

    Use these instructions to create activities that can be called directly in flows.

  • Unit testing a Service SOAP rule

    Services start their processing in response to a request from an external application. Before you add the external application to your testing process, use the Simulate SOAP Service Execution feature to verify that the service processes data appropriately. When using this feature, you manually provide some representative data to process. You specify a test page for the rule to use, provide sample data as the input, run the rule, and examine the results to see if they are what you expect.

  • Creating a rule

    To save time and ensure that your projects adhere to the unique needs of your clients, create rules and data instances using reusable elements of your application. By combining a rule type, name, class, and ruleset, you provide a unique identity for each rule that you create.

  • Branches and branch rulesets

    Typically, you use branches in development environments in which multiple teams contribute to a single application. You use branches to develop software in parallel in a version-controlled environment. For example, your teams can develop one feature in a branch while another team develops a feature in a different branch, even if they share the same base rulesets.

If you are having problems with your training, please review the Pega Academy Support FAQs.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice