Conditions and Expressions
  • 03 Sep 2024
  • 1 Minute to read
  • Contributors
  • Dark
    Light
  • PDF

Conditions and Expressions

  • Dark
    Light
  • PDF

Article summary

Xponent uses Expressions extensively within Business Logic and for Conditional branches in graphs. Each expression can be defined in one of two ways: Basic or Advanced. Both of these techniques generate a JavaScript expression, which is evaluated for truthfulness. 

Basic Expressions

Basic expressions provide a dropdown list of common expressions which are available to be used: 

Selecting Advanced from the dropdown shows a JavaScript expression window that allows any valid JavaScript Boolean expression to be entered.

By default, the equivalent JavaScript will be shown when switching from the Basic to the Advanced view.

Basic ExpressionArgumentsEquivalent JavaScriptNote
Is TrueNoneVAL === true
Is FalseNoneVAL === false
Less Than or Equal ToConstant Value - numeric or stringVAL <= 12.3
Greater ThanConstant Value - numeric or stringVAL > 12.3
Greater Than or Equal ToConstant Value - numeric or stringVAL >= 12.3
 Equals

Constant Value - numeric, string, or booleanVAL == {...}
  Not Equal ToConstant Value - numeric, string, or booleanVAL != {...}
 ContainsConstant StringVAL.indexOf('abc') > -1

This method is case-sensitive. Make sure you manipulate as necessary to make it case insensitive.

 Starts WithConstant StringVAL.indexOf("abc") === 0

This method is case-sensitive. Make sure you manipulate as necessary to make it case insensitive.

 Ends WithConstant StringVAL.lastIndexOf("abc") === VAL.length - "abc".length

This method is case-sensitive. Make sure you manipulate as necessary to make it case insensitive.

Advanced Expressions

Advanced expressions are any valid boolean JavaScript (ECMAScript 5) expressions. The JavaScript variable 'VAL' is always available and is set to the Value of the previous node when used as an expression on a conditional branch. 

If the Basic Expressions do not have the type of operator that you require, then the advanced mode should allow you to program your own condition. Examples include: 

Description
Conditional
JavaScript
Membership of a list. Test to see if the returned Value is in a list of values.
['worda', 
 'wordb', 
 'wordc'].indexOf(VAL) >= 0
Check if a javascript object is empty or not
Object.keys(obj).length === 0 && obj.constructor === Object

Miscellany 

It is worth taking note that JavaScript has some interesting outcomes when compared against null: 

  • null >= 0 → true
  • null <= 0 → true
  • null == 0 → false
  • +null == 0 → true

Is it helpful? React and share your comment

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence