Evaluates an C# expression and assigns the value to variable

Last published at: May 14th, 2024

Description:

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 properties
  • Configure the following values for the properties as shown on the below graphic

  • Click on the Expression to evaluate field. Press Alt+E on keyboard to invoke the Expression Builder. This utility shall enable to build and validate expressions as shown in the image below. Send the expression to clipboard and paste the same 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()

  • Save the process definition, create a workflow instance and execute.  Step should evaluate the expression.