Defining the local variables for an activity
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.
- In the navigation pane of Dev Studio, click Records.
- Expand the Technical category, and then click Activity.
- Open the activity that you want to configure.
- Click the Parameters tab.
- 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.
- 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.
- In the Data type list, select the type of data that the value
for the variable has:
- For a
Java.lang.stringobject, select String.
- For a Java
StringBufferobject, 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
BigDecimalclass, 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
Stringlocal variables to the empty string, and the
StringBufferlocal variable as:
public StringBuffer aBuffer = new StringBuffer();
- For a
- Optional: To define another local variable, click Add item, and then repeat steps 5 through 7.
- 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.
Previous topic Security tab on the Activity form Next topic Activity form - how to create activities for flows