Use fields, functions, and operators to create expressions in the Expression Editor.
If you assign the value Formula to a field, you must create a formula or an expression for the field to take data from. Use the Expression Editor to create expressions.
In the following image, fields str and str2 have the value Formula:
Note: The Expression Editor comes with powerful functions that can invoke operating system features. You must review the content passed into the functions before using them.
To open the Expression Editor, click f(x) next to a field wit h the value Formula.
The following image shows the Expression Editor dialog box:
The Expression Editor contains the following sections:
•Section 1, the Fields section. A list of input, output, and temporary fields that you define appears here.
•Section 2, the Functions section. A list of common XQuery functions appears here. Select a function to view its meaning.
•Section 3, the Operators section. A list of operators that you can use to build an expression appears here.
•Section 4, the Expression section. The Expression you build appears here. The conditions and operators that you use are case sensitive.
The expression in the image defines a temporary field, Total Status, as Pass if three tasks that run in parallel succeed.
Next, the taskflow uses Total Status in a Data Decision step. If the value of Total Status is Pass, the taskflow runs another Data Task. If the value of Total Status is Fail, the taskflow ends.
The following image shows the taskflow that uses Total Status:
Use the following options to create an expression:
•To add a field, click the Fields tab, drill down to the field that you want to use, and click Add.
•To add an operator, click an operator in the Operators section. You can also manually enter an operator. For example, manually enter the If operator.
•To add a function, click the Functions tab, drill down to the function you want to use, and click Add.
•To add a comment, enter the comment in the Expression section with the following syntax:(:<comment>:).
For example, enter (:This is a sample comment:).
Use comments to give descriptive information about the expression or to specify a URL to access business documentation about the expression.
The Expression Editor validates the expression as you enter it. You cannot save an expression that is not valid.
Tips: Using XQuery 3.0 to create expressions
Use XQuery version 3.0 to create expressions in the Expression Editor. The samples in this topic show you the syntax and the elements that you use to construct single statement and multi statement XQuery expressions.
The following expression is a single statement expression:
concat("Hello"," ",$input.n1)
The following notes explain the parts of this expression:
•concat is a function that joins two or more values into a single string.
•"hello", " "$input.n1 are the parameters of the function concat.
- "hello" is a string. Always include a string within quotes. You may use single or double quotes. However, ensure that you use the same style within an expression.
- n1 is an input variable. When you add it to an expression, the Expression Editor converts it to $input.n1. Always prefix a variable with a $. Do not add quotes around variables.
- The parameter " " denotes space.
•Include parameters within parentheses.
•Separate parameters with commas.
Assume that the value of $n1 is "World".
If you run:
concat("Hello", " ",$input.n1)
you get the following output:
Hello World
Multi-statement expression
The following expression is a multi-statement expression:
let $n1 := number($input.n1) let $n2 := number($input.n2)
let $r1 := if ($n1 > $n2) then "Greater: N1 > N2" else if ($n1 < $n2) then "Less: N1 < N2" else "Same" return $r1
The following notes explain the parts of this expression:
•First, you declare the variables $n1 and $n2. Use the operator := to assign a value.
Note: Even if you defined $n1 and $n2 as integers in an Assignment step, you must declare them as numbers in the Expression Editor.
•You can use XQuery keywords such as let, if, then, and else. They are case sensitive.
Important: If you start an expression with the keyword let, you must end the expression with the keyword return.
•We use the Expression Editor to define the value of a third variable $r1 using the following rules:
- If the value of $n1 is greater than the value of $n2, $r1 takes the value: Greater: N1 > N2.
- If the value of $n1 is less than the value of $n2, $r1 takes the value: Less: N1 < N2.
- If the values of $n1 and $n2 are the same, $r1 takes the value: Same.
Assume that the value of $n1 is 20 and the value of $n2 is 250.
If you run:
let $n1 := number($input.n1) let $n2 := number($input.n2)
let $r1 := if ($n1 > $n2) then "Greater: N1 > N2" else if ($n1 < $n2) then "Less: N1 < N2" else "Same" return $r1
you get the following output:
Less: N1<N2
Here, $r1 now has the value
Less: N1<N2
Keyboard shortcuts
You can use keyboard shortcuts when you create an expression.
To use keyboard shortcuts, place the pointer inside the Expression section.
The following keyboard shortcuts are available:
Action
Shortcut
Undo
Ctrl+Z
Redo
Ctrl+Y
Copy
Ctrl+C
Cut
Ctrl+X
Paste
Ctrl+V
Find
Ctrl+F
Indent four spaces
Tab
Show list of available variables
$
Code Completion, that is, show a list of available insertions. The insertions might be name spaces, functions, fields, or common code fragments.