Evaluates an C# expression and assigns the value to variable

Use this step to evaluate an C# expression.

Last published at: July 27th, 2024

evalExpression Step

Description:

This step evaluates a given expression and assigns the result of the expression to a variable.

 

 Inputs

  • Expression – expression to evaluate
  • variableName – name of the variable to store the resulting value from the expression 
 

 

Returns

  • True – expression evaluated successfully
  • False – expression failed to evaluate 
 

 

Usage:

 

 

Example:

Let’s build and execute the “evalExpressionDef” example.                         

  • Create a new definition called “evalExpressionDef”
  • Select the definition and click the “design” button
  • Drag a “evalExpression” step to the canvas
  • Connect the dots between the start and evalexpression step
  • Click on the "evalExpression" step to configure its "Settings" properties. Provide a name to the step. 

 

  • Click on the Expression to evaluate the field. Press Alt+E on the keyboard to invoke the Expression Builder. This utility enables you to build and validate expressions, as shown in the image below. Send the expression to the clipboard and paste it in the input field. 

 

  • In the expression to evaluate below, the system sets the default calendar for any culture to be the Gregorian calendar and hence local calendars viz Egyptian, Roman, Thai shall now display the current date, month and year.  

 

  • Examples for expression to evaluate:
    e.g. Variable.number + 10    
    e.g. Global.testNumber + 100 / Variable.colNum
    e.g. Variable.data + "test"
    e.g. Global.hasData == 1
    e.g. DateTime.Today.ToString()
    e.g. DateTime.Today.AddDays(14).ToString()

 

  • The “Logging” setting configuration is necessary for documentation and also measures the workflow progress and the percent complete. This is achieved by configuring the step state and percent fields individually, as shown in the images below. Configure the “Logging” using the following properties.

 

  • Save the process definition, create a new process instance, and execute. Render the process instance. Click on the process step to view its properties. The step should evaluate the expression and return TRUE or FALSE to the variable configured.