Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Defining the local variables for an activity

Updated on January 14, 2022

Create scalar variables that you can use to pass information between the steps of an activity. Local variables require less memory and run faster than regular parameters.

For example, you can simplify a highly nested expression by using local variables to break up that expression into component parts. As a result, the expression is easier to read and troubleshoot.

Your application stores local variables together as fields in the Java class that Pega Platform generates to implement the activity. Local variables do not appear on the parameter page.

You can reference a local variable in a Property-Set method by using the Local keyword, as well as in Java steps.

  1. In the navigation pane of Dev Studio, click Records.
  2. Expand the Technical category, and then click Activity.
  3. Open the activity that you want to configure.
  4. Click the Parameters tab.
  5. In the Local variables section, in the Name field, enter a unique identifier for the local variable.
    You can choose any valid Java identifier. Do not choose a name that starts with pz or any of the reserved names.
  6. In the Description field, enter text that describes how your rule logic processes the local variable, so that other developers can understand that rule more quickly.
  7. In the Data type list, select the type of data that the value for the variable has:
    • For a Java.lang.string object, select String.
    • For a Java StringBuffer object, select StringBuffer.
    • For a Java integer, select Integer.
    • For a Java double, select Double.
    • For a Java Boolean, select Boolean.
    • For a Java char, select Char.
    • For the BigDecimal class, select BigDecimal.
    • For any Java object, select Object.
    Note: An application can assemble a local variable of the StringBuffer type in multiple steps, because a Property-Set method on a string buffer class appends the value to the string buffer.
    Note: To avoid Java null pointer exceptions, the system initializes String local variables to the empty string, and the StringBuffer local variable as: public StringBuffer aBuffer = new StringBuffer();
  8. Optional: To define another local variable, click Add item, and then repeat steps 5 through 7.
  9. Optional: To use a flow action at run time that produces a prompt form in which the user can enter values for the flow parameters that are specified in this tab, in the Local action for parameter display section, specify the flow action.
    For more information, see Prompting users for parameter values.

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

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.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us