Conditions and Expressions

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 generates a JavaScript expression which is evaluated for truthfulness. 

Basic Expressions

Basic expressions provide a drop down 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 when switching from the Basic to the Advanced view the equivalent JavaScript will be shown. 



Basic Expression

Arguments

Equivalent JavaScript

Note

Basic Expression

Arguments

Equivalent JavaScript

Note

Is True

None

VAL === true



Is False

None

VAL === false



Less Than or Equal To

Constant Value - numeric or string

VAL <= 12.3



Greater Than

Constant Value - numeric or string

VAL > 12.3



Greater Than or Equal To

Constant Value - numeric or string

VAL >= 12.3



Equals

Constant Value - numeric, string or boolean 

VAL == {...}



Not Equal To

Constant Value - numeric, string or boolean 

VAL != {...}



Contains

Constant String

VAL.indexOf('abc') > -1

This is case sensitive.



Starts With

Constant String

VAL.indexOf("abc") === 0

This is case sensitive. See this Knowledge Base article on how to make it case insensitive.

Ends With

Constant String

VAL.lastIndexOf("abc") === VAL.length - "abc".length

This is case sensitive. See this Knowledge Base article on how 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

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 comparing against null: 

  • null >= 0 → true

  • null <= 0 → true

  • null == 0 → false

  • +null == 0 → true



Privacy Policy
© 2022 CSG International, Inc.