Expressions

Expressions are a way to specify the inputs for an activity when you don't know what the input's value will actually be. Expressions specify how to find or compute input values when the workflow runs.

The most common use for expressions is to access the output of activities that have already run. For example, if you have an activity that calculates the length of a geometry, you could follow it with an activity that displays the calculated length. When you build the workflow, you don't know what the actual length will be, but you do know which activity will calculate the length, so you use an expression that gets the output of the activity that calculated the length.

To help you build expressions, Geocortex Workflow Designer provides auto-complete suggestions when you enter an expression. This allows you to select from a list of possible items for each part of the expression.

Use Expressions

In Workflow Designer, expressions always start with an equals sign (=). The equals sign tells Workflow Designer to expect an expression.

Expressions are made up of terms. The simplest expression has a single term, for example, =12. More complex expressions have multiple terms that are combined according to the operators given in the expression, for example, =12*37/2. In either case, expressions evaluate to a single value of a particular type—numeric expressions evaluate to a value of type Number, Boolean expressions evaluate to a value of type Boolean (true or false), string expressions evaluate to a value of type String, and so on.

To access the output of an activity, you must use an expression. The term that refers to the output starts with a dollar sign ($). The form of an expression that accesses a simple activity output is:

=$[activity_ID].[output_name]

For example, an expression that accesses the result output of a Get Absolute Value activity with ID abs1 is as follows:

=$abs1.result

You can use activity outputs in complex expressions, for example:

=$abs1.result * 23

In this expression, the first term ($abs1.result) refers to the value of a particular activity output and the second term (23) is a literal. A literal does not require interpretation—it is the value itself.

If an expression only has one term and it is a literal, you do not need to use an expression—you can simply enter the literal value in the input box. For example:

Use String Expressions

String expressions are expressions that evaluate to a value of type String. String literals are simply text, for example, This is a string literal. Like literals of other types, string literals can be expressed as an expression (="This is a string literal"). They can also be combined (concatenated) with other strings in complex expressions.

Concatenating strings in an expression allows you to build complete sentences and other meaningful strings that contain dynamic values, such as activity outputs. For example, suppose your workflow contains a Prompt activity that gets a name from the user. You might want to display the name back to the user to confirm that it is correct. You use a Confirm activity to do this. You want the Confirm activity's message to say You entered [name entered by the user]. Is this correct?

There are two ways to configure this message in Workflow Designer:

Quotes have a special meaning in strings that are concatenated using the plus operator: they surround literals. Similarly, backticks have a special meaning in template literals. If you want one of these special characters to appear in the output string, put a backslash (\) before it. For example, suppose you want the confirmation message to put double quotes around the name entered by the user: You entered "[name entered by the user]". Is this correct? To configure this message using the plus operator, you would put a backslash before the quote mark at each end of the name:

="You entered \"" + $prompt1.result + "\". Is this correct?"

Alternatively, you could use single quotes around the literals. In this case, you don't need backslashes:

='You entered "' + $prompt1.result + '". Is this correct?'

Some string inputs in Geocortex Workflow can contain multiple lines of text. For example, the Confirm activity's Text input allows multiple lines. Suppose you want the confirmation message to appear on two lines:

You entered [name entered by the user].
Is this correct?

You can use \n to go to a new line in strings configured using either method:

Template literals also allow you to simply press Return to go to a new line, so your configuration has the same lines as the string that is displayed to the user. For example, you could configure the Confirm activity's Text input like this:

=`You entered ${$prompt1.result}.
Is this correct?`

Sometimes you may need to configure a numeric value in a string input. In this case, you must enter the value as an expression. For example, to enter the number 123 in a string input, enter: ="123"

See also...

Template Literals

Example - Enter an Expression to Access Another Activity’s Output

This example illustrates how to use Workflow Designer's auto-complete suggestions to enter an expression that accesses the output of a previous activity. The example workflow has a Display Form activity followed by an Alert activity.

Workflow Logic

The workflow has the following activities, in the order shown:

  1. In Workflow Designer, create a new, blank workflow.

    To create a blank workflow, click File in the sidebar, click New, select Blank Workflow, and click Create.

  2. Create a form with a Text Box element and configure the text box's settings. Set Title to City. Set Default Value to Lisbon.

    To create the form:

    1. Drag a Display Form activity from the Toolbox and drop it on the Start block to position and connect the activity.

      The activity's ID is form1.

    2. Double-click the Display Form activity to open the form for editing.

    3. Drag a Text Box element from the Toolbox and drop it between Form Title and the Submit and Cancel buttons.

      The text box's ID is TextBox1.

    4. Configure the text box's Title and Default Value.

      The form should look like this:

  3. Click Start in the breadcrumbs to return to the main workflow.

  4. Add an Alert activity and configure it to display the value of the Display Form's City element.

    You will use Geocortex Workflow Designer's built-in auto completion to build the expression.

    Instead of using auto completion, you can type in expressions if you want. Make sure you match the capitalization used in Workflow Designer, as expressions are case sensitive.

    To create the expression that accesses the city entered by the user:

    1. Enter an equals sign (=) in the Alert activity's text input to indicate that you are going to enter an expression. This activates the auto-complete suggestions that will help you to create expressions.

      A drop-down list opens. The list shows the IDs of the other activities in the workflow. In this case, the workflow only has one other activity, the Display Form activity. The ID of the Display Form activity is form1.

    2. Select $form1 to add it to the expression.

    3. Type a period (.) to open the next drop-down list of auto-complete suggestions.

    4. Select state to add it to the expression.

    5. Type a period.

    6. Select TextBox1 to add it to the expression.

      TextBox1 is the ID of the City element.

    7. Type a period.

    8. Select value.

      The expression should look like this:

  5. Save your workflow.

  6. To test your workflow, run the workflow in the Sandbox.

    To run a workflow in the Sandbox, click Info in the sidebar, click Run in Sandbox, select the environment, and then click Run Workflow. You can press F12 at any time to see the verbose log.

© 2018 Latitude Geographics Group Ltd. All Rights Reserved.

Documentation Version 5.9