Navigation:  Appendix >

Boolean Expression

Previous pageReturn to chapter overviewNext page

Boolean expression evaluation is a little known feature in Enterprise Forms. It exists as a standard Operator in all Conditional evaluations throughout the system. Relatively easy to use but provides a powerful way of combining evaluation of expressions from multiple sources.

 

A “Boolean expression” is any valid expression that returns a true or false value. A valid expression is a statement with containing a supported comparison operator with the exception when functions are used.

 

The following are examples of valid boolean expressions

1 + 2 == 3

evaluates to true because the sum from the left side of the operator equals to 3.

 

“Hello” == “hello”

evaluates to false because the word “Hello” is not the same as “hello” due to case-sensitive comparison.

 

hello == hello

evaluates to false because String values from 2 sides of the operator require double quotes (“) to be wrapped around such as “hello” == “hello”

 

Common Operators

Boolean expression supports a number of comparison operators as as well as bitwise operators

 

Operator/Bitwise

Description

==

Equal – returns true if values from both left and right side of the Operator are the same.
e.g. “Hello” == “Hello” evaluates to true

!=

Not Equal – returns true if values from both left and right side of the operator are not the same.
e.g. “Hello” != “Hello” evaluates to false

>

Greater Than – returns true if value from the left side of the operator is greater than the right side.
e.g. 1 > 2 evaluates to false

>=

Greater Than or Equals – returns true if value from the left is greater or equals to the value from the right side.
e.g. 2 >= 2 evaluates to true

<

Less Than – returns true if value from the left is less than value from the right side.
e.g. 1 < 2 evaluates to true

<=

Less Than or Equals – returns true if value from the left is less than or equals to value from the right.
e.g. 3 <= 3 evaluates to true

&&

And – bitwise AND operation between two sub expressions.
e.g. 2 > 1 && 4 > 3 evaluates to true because 2 > 1 AND 4 > 3

||

OR – bitwise OR operation between two sub expressions.
e.g. 2 < 1 || 4 > 3 evaluates to true because 4 > 3 although is not 2 < 1

 

Token Support

 

Boolean expression provides full support for single bracket tokens. The following shows some of the examples on the use of tokens in boolean expression.

 

Username comparison

“[USERNAME]” == “Joe Bloe”

returns true if the username of the current logged user is “Joe Bloe”

 

Current state comparison

“[STATENAME]” == “Submitted” || “[STATENAME]” == “Saved”

returns true if the current state name is Submitted or Saved

 

String Functions

 

The following string functions are supported in boolean expressions

 

Function

Description

Equals

Determines whether string values are the same.
e.g. String(“Hello”).Equals(“Hello”) evaluates to true because the string “Hello” is equal to “Hello”

CompareTo

Returns a numeric value to whether the the string values are the same.

Returns 0 if two values are the same
Returns 1 if the string value is greater than the compare value
Returns –1 if the string value is less than the compare value

Example

String(“Hello World”).CompareTo(“Hello World”) == 1 evaluates to true

String(“Hello World”).CompareTo(“Hello”) == 1 evaluates

String(“Hello World”).CompareTo(“Hello World 2”) == –1 evaluates to true

EndsWith

Determines whether the end of the string matches a specified string.
e.g String(“Hello World”).EndsWith(“World”) evaluates to true

StartsWith

Determines whether the start of the string matches a specified string.
e.g String(“Hello World”).StartsWith(“Hello”) evaluates to true

IndexOf

Returns the index first occurrence of the specified string. Returns –1 if string not found.
e.g String(“Hello World”).IndexOf(“World”) == 5 evaluates to true

LastIndexOf

Returns the index of the last occurrence of the specified string. Returns –1 if string not found.
e.g. String(“Hello World World”) == 11 evaluates to true

Replace

Replaces all occurrences of a specified value with another give value.
e.g. String(“Hello World”).Replace(“World”, “Joe”) == “Hello Joe” evaluates to true

Trim

Remove spaces from the beginning and end of string.
e.g. String(“ Hello World “).Trim() == “Hello World” evaluates to true

SubString

Retrieves a substring from the instance. Usage: SubString(startIndex, length)
 
e.g. String(“Hello World”).SubString(0, 5) == “Hello” evaluates to true

ToLower

Converts string to all lower case.
e.g. String(“Hello World”).ToLower() == “hello world” evaluates to true

ToUpper

Converts string to all upper case
e.g. String(“Hello World”).ToUpper() == “HELLO WORLD” evaluates to true