Evaluate Dynamic Expression
  • Updated on 23 Jul 2014
  • 4 minutes to read
  • Print
  • Dark
    Light

Evaluate Dynamic Expression

  • Print
  • Dark
    Light

Overview

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:

NAME DESCRIPTION USAGE RESULT
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
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'

Example

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 .
2018-01-03_110758.png

Name the Flow and click OK to continue.
2018-01-03_110916.png

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.
2018-01-03_110957-1024x768.png

Double click the [Pick or Create Form] step and select Pick or Create Form.
2018-01-03_111045-1024x768.png

We name the Form and click Create to Continue.
2018-01-03_111130-1024x764.png

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.
SimpleCalculator.png

Save and close the form to return back to the  Flow Designer .
2018-01-03_111921.png

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.
2018-01-03_112122.png

Select the  Evaluate Dynamic Expression step and choose  Edit Input Mapping.
2018-01-03_112205-1024x768.png

In the Mapping Editor choose Text Merge.Plain type of input for the expression value.
2018-01-03_115131-1024x334.png

Next, click on Show Editor to open the  Text Merge.Plain Editor .
2018-01-03_115150-1024x308.png

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 .
2018-01-03_115659-1024x716.png

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.
2018-01-03_115953.png

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.
2018-01-03_120136.png

From this step's options we choose Pick or Create Form , name our Result Form and click Create to continue.
2018-01-03_120225.png

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.
2018-01-03_125241.png

Next, we save and close our Result Form to get back to our Flow Designer .
We connect our steps and it completes our flow.
2018-01-03_125333.png

To test the result click Debug Flow link from the top panel of the Flow Designer.
2018-01-03_125345.png

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.
2018-01-22_112737.png

The Diagram shows that our Flow ran with No Errors
2018-01-22_112753-1024x163.png

Was this article helpful?