Set Scoped Variables activity

An activity that sets the scope for one or more variables.


Set Scoped Variables activity

Configure the Set Scoped Variable activity

Examples

Prerequisites

Good to Know

How to Start

  1. Open Process Builder.

    For information about how to open this screen, refer to Process Builder.


    Open Process Builder
  2. In Process Builder, in the Activity Library, open the Common tab.

    Open Common tab
  3. On the Common tab, drag the Set Scoped Variables activity onto your process.

    Drag Set Scoped Variables activity

General Configuration

Specifies the basic settings for the Set Scoped Variables activity.

Figure: General Configuration screen

General Configuration screen

Fields

Field NameDefinition

Display Name

Description:
Specifies the activity name that shows in your process.
Allowed Values:
One line of text (a string).

Accepted:

  • Letters
  • Numbers
  • Spaces
Default Value:
None
Accepts Variables:
No
Example:
This is a common configuration field that is used in many examples. Refer to:
  • Examples - Step-by-step use case examples, information about what types of examples are provided in the AgilePoint NX Product Documentation, and other resources where you can find more examples.

Description

Description:
Specifies an optional text description for your activity.
Allowed Values:
More than one line of text.
Default Value:
None
Accepts Variables:
No

Set Scoped Variables

Specifies the information to set the scope for one or more variables.

Figure: Set Scoped Variables screen

Set Scoped Variables screen

Fields

Field NameDefinition

Reference ID

Description:
Specifies a scope to set for the scoped variable.

Any scope that is used represents a unique ID that can be passed from the Set Scoped Variables activity to the Get Scoped Variables activity. All of these options are simply different types of IDs. The different ID options are provided for convenience or to match your business requirements. For example, you could use Process Instance ID for one Set Scoped Variables activity and Activity Instance ID for another Set Scoped Variables activity in the same process model. This would provide the option of two different automatically generated IDs. However, there is no difference in the functionality between the two ID types.

To values for the scoped variable, you must select the same ID type in the Get Scoped Variables activity. For more information, refer to Get Scoped Variables activity.

Allowed Values:
  • A scope from the list.
    • Process Instance ID - Uses the current process instance ID to set the scope for the variable.

      As a best practice, it is recommended to use this option only if you have only one Set Scoped Variables activity in a process. All Set Scoped Variables activities configured to use Process Instance ID will have the same associated ID.

    • Activity Instance ID - Uses the activity instance ID for the current Set Scoped Variable activity to set the scope for the scoped variable.
    • Generate New GUID - Creates a custom scope ID in GUID format to set the scope for the variable.
  • One line of text (a string) that represents a unique scope name.
Default Value:
None
Accepts Variables:
Yes

Add Add icon

Function:
Adds a row for the Variable and Expression fields.

Validate Validate icon

Function:
Makes sure the value specified in the Expression field is correct, and shows the error message if an error occurs.

Variable

Description:
Specifies a scoped variable whose scope to set.

This variable is limited to show the value in a process based on the scope specified in the Reference ID field.

Allowed Values:
A variable.
Default Value:
None
Accepts Variables:
Yes

Expression

Description:
Specifies the value for the scoped variable.
Allowed Values:
Behind the scenes, the value in the Expression field is converted to complete this C# phrase:

ds["/pd:AP/pd:formFields/pd:message"] = dsNew["/pd:AP/pd:formFields/pd:message"] = {Expression field value};

As such, it is possible to have several different types of values, but in most cases, they must follow C# syntax.

You can use any of the types of values in this list.

A literal string value.

  • The string value must be enclosed within the quotation marks (" ").
  • The string must be in valid C# string format, which means no special characters that would cause the string to be misinterpreted as C# code.

Examples:

  • "Mary Poppins"
  • "8675309"

Behind the scenes, this creates C# code that looks like this:

ds["/pd:AP/pd:formFields/pd:message"] = dsNew["/pd:AP/pd:formFields/pd:message"] = "8675309";

A variable.

If you use a variable in the Expression field, it initializes, or sets, the value of the variable in the Process Data Variable field to the current value of the variable in the Expression field when the Update Process Data activity runs.

  • You can use process data variables in either of these formats:
    • Process data - ${EmployeeName}
    • Xpath - ${/pd:myFields/pd:empName}
  • Do not enclose variables with quotation marks (" ").

Behind the scenes, this creates C# code that looks like this:

ds["/pd:AP/pd:formFields/pd:message"] = dsNew["/pd:AP/pd:formFields/pd:message"] = ds.Attr("/pd:AP/pd:myFields/pd:empName", pi, w);

A C# code snippet.

This is advanced functionality, and knowledge of the C# programming language is required. AgilePoint does not provide detailed documentation on how to use C# code in general. These are rules to understand if you already know how to program with C#. If you would like help with this feature, please contact AgilePoint Professional Services.

  • Any .NET methods must be available in one of these namespaces:
    • System
    • System.Collections
    • Ascentn.Workflow.Base
  • If you use variables in the C# snippet, they must obey these rules:
    • You can use either AgilePoint formatting or standard C# formatting.

      For example, you can use the format ${EmployeeName} or ds.Attr("EmployeeName", pi, w);

      The same as when you use only a variable in the Expression field, if you use the AgilePoint variable format, it is converted to C# format behind the scenes.

    • Your C# code must use type casting for the variables.

Example:

(${/pd:AP/pd:formFields/pd:employee1}).ToString().ToUpper() + " and " +(${/pd:AP/pd:formFields/pd:employee2}).ToString().ToUpper()

In this example, the values of employee1 (Poppins) and employee2 (Van Dyke) are converted to all capital letters (UPPER CASE). It also combines both values with the word "and". This is the result: POPPINS and VAN DYKE.

Behind the scenes, this creates C# code that looks like this:

ds["/pd:AP/pd:formFields/pd:message"] = 
dsNew["/pd:AP/pd:formFields/pd:message"] 
= ds["/pd:AP/pd:formFields/pd:message"] = 
dsNew["/pd:AP/pd:formFields/pd:message"] 
= (ds.Attr("/pd:AP/pd:formFields/pd:employee1", 
pi, w)).ToString().ToUpper() 
+ " and " 
+(ds.Attr("/pd:AP/pd:formFields/pd:employee2", 
pi, w)).ToString().ToUpper();
Default Value:
None
Accepts Variables:
Yes

Edit Edit icon

Function:
Changes the expression value for a scoped variable.

Delete Delete icon

Function:
Deletes the selected row from the variable list.