Evaluate Dynamic ExpressionLast Updated: 05/02/2018 Introduced in Version: 2.0
Expression Steps are designed to evaluate calculations in one step. This step can be found under All Steps [Catalog] > Data > Numbers > Evaluate Dynamic Expression. The Evaluate Dynamic Expression step is unique in the way that it allows end User to evaluate any expression. In other words, we can pass the entire dynamic expression from the Flow to this step.
Here is a list of expressions that you can use in the Evaluate Expression step:
|Abs||Returns the absolute value of a specified number.||Abs(-1)||1M|
|Acos||Returns the angle whose cosine is the specified number.||Acos(1)||0d|
|Asin||Returns the angle whose sine is the specified number.||Asin(00||0d|
|Atan||Returns the angle whose tangent is the specified number.||Atan(0)||0d|
|Ceiling||Returns the smallest integer greater than or equal to the specified number.||Ceiling(1.5)||2d|
|Cos||Returns the cosine of the specified angle.||Cos(0)||1d|
|Exp||Returns e raised to the specified power.||Exp(0)||1d|
|Floor||Returns the largest integer less than or equal to the specified number.||Floor(1.5)||1d|
|IEEERemainder||Returns the remainder resulting from the division of a specified number by another specified number.||IEEERemainder(3, 2)||-1d|
|Log||Returns the logarithm of a specified number.||Log(1, 10)||0d|
|Log10||Returns the base 10 logarithm of a specified number.||Log10(1)||0d|
|Max||Returns the larger of two specified number.||Max(1, 2)||2|
|Min||Returns the smaller of two numbers.||Min(1, 2)||1|
|Pow||Returns a specified number raised to the specified power.||Pow(3, 2)||9d|
|Round||Rounds a value to the nearest integer or specified number of decimal places. The mid number behavior can be changed by using EvaluateOption.RoundAwayFromZero during construction of the Expression object.||Round(3.222, 2)||3.22d|
|Sign||Returns a value indicating the sign of a number.||Sign(-10)||-1|
|Sin||Returns the sine of the specified angle.||Sin(0)||0d|
|Sqrt||Returns the square root of a specified number.||Sqrt(4)||2d|
|Tan||Returns the tangent of the specified angle.||Tan(0)||0d|
|Truncate||Calculates the integral part of a number.||Truncate(1.7)||1|
|In||Returns whether an element is in a set of values.||in(1 + 1, 1, 2, 3)||true|
|If||Returns a value based on a condition.||if(3 % 2 = 1, ‘value is true’, ‘value is false’)||‘value is true’|
In this Example we will create a Simple Calculator using an Interaction Form. Having an interaction form allows an end user to interact with the form to determine which numbers and mathematical operation they would like to use.
To begin building navigate to a Designer Folder and select Create Flow.
Name the Flow and click OK to continue.
In the Flow Designer’s Quick Add window under Flows, Rules, Forms and Reports > Forms [Interaction] locate [Pick or Create Form] and click Add to add it to the workspace.
Double click the [Pick or Create Form] step and select Pick or Create Form.
We name the Form and click Create to Continue.
Once we click Create the Form Designer is opened.
This Form is designed with a Label, two Number Boxes, a Dropdown List to pick an operation, and an Action button.
Save and close the form to return back to the Flow Designer.
Connect the Form Step to the Flow’s Start step. Under All Categories [Catalog] > Data > Numbers locate Evaluate Dynamic Expression and add it to the workspace. Connect our Form Step outcome to the Evaluate Dynamic Expression step.
Select the Evaluate Dynamic Expression step and choose Edit Input Mapping.
In the Mapping Editor choose Text Merge.Plain type of input for the expression value.
Next, click on Show Editor to open the Text Merge.Plain Editor.
Inside of the Text Merge Editor add the Number1 value to the editor. This [FirstNumber] value refers to the a value that a specific text box is populated with. Similarly, add [Operator] and [SecondNumber] to the Merge Text workspace. This completes our Dynamic Expression Builder. Click OK to save and close Text Merge Editor. We could just use a TextBox in our Form to let the user input the Expression into it and pass the outcome string into our Evaluate Dynamic Expression Step.
Close the Input Mapping Editor and in in the Mapping Editor we rename its Outcome to Result. This completes our Mapping so we click Ok to save and close it.
Next we need to create another Form to Display the result of our Calculation. Just like we did with the first form in this flow we locate [Pick or Create Form] step under Forms[Interaction] category and drag it to the workspace. We connect this step to our Evaluate Dynamic Expression step.
From this step’s options we choose Pick or Create Form, name our Result Form and click Create to continue.
Our Result Form is designed as follow…It has a Title which is a simple Label. It has an Action Button to close the Form. And it has Value Labels from the Flow Data to Display our Calculation.
Next, we save and close our Result Form to get back to our Flow Designer.
We connect our steps and it completes our flow.
To test the result click Debug Flow link from the top panel of the Flow Designer.
Our first form opens in the Debugger and we can input some parameters in it. After we click Equals we can see our Result Form with the correct answer. Next, click Done to close the form.
The Diagram shows that our Flow ran with No Errors.