Conditions and expressions

Acquia Journey uses expressions extensively in 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 that is evaluated for truthfulness.

Basic expressions

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

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 - number, string, or boolean VAL == {...}  
Not Equal To Constant Value - number, string, or boolean VAL != {...}  
Contains Constant String VAL.indexOf('abc') > -1 Case-sensitive — see Case-insensitive expressions
Starts With Constant String VAL.indexOf("abc") === 0 Case-sensitive — see Case-insensitive expressions
Ends With Constant String VAL.lastIndexOf("abc") === VAL.length - "abc".length Case-sensitive — see Case-insensitive expressions

Advanced expressions

Advanced expressions are any valid boolean JavaScript (ECMAScript 5) expressions. The JavaScript variable VAL is 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, the advanced mode should allow you to program your own condition. To access the advanced mode, in the Type list, click Conditional, select Advanced.

The following examples are available for your use:

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

Case-insensitive expressions

The basic conditions Contains, StartsWith, and EndsWith are case-sensitive. For example, the string dog would not match the string DOG.

To create a case-insensitive condition in an existing graph, create an Advanced Expression on the branch, and use the JavaScript toLowerCase() function using these steps:

Example graph

  1. Create your Set node
    1. Right-click in the background of your graph, and then click Add Node to Graph.
    2. Scroll to the Basic Nodes section, and then double-click Set to add it to your graph.
    3. Click the Set node to select it.
    4. In the sidebar, scroll to the Edit Set Node panel, and then define the node's value as a child value in your schema.
  2. Create your Get node
    1. Right-click in the background of your graph, and then click Add Node to Graph.
    2. Scroll to the Basic Nodes section, and then double-click Get to add it to your graph.
    3. Link the Set and Get nodes together with a Goto.
    4. Click the Get node to select it.
    5. In the sidebar, scroll to the Edit Get Node panel, and then define the value to GET that value from your schema.
  3. Create your Return False node
    1. Right-click in the background of your graph, and then click Add Node to Graph.
    2. Scroll to the Basic Nodes section, and then double-click Return to add it to your graph.
    3. Link the Get and Return False nodes together with a Goto.
  4. Create your Return True node
    1. Right-click in the background of your graph, and then click Add Node to Graph.
    2. Scroll to the Basic Nodes section, and then double-click Return to add it to your graph.
    3. Link the Get and Return True nodes together.
    4. Click the link between your Get and Return True nodes (currently Goto). In the sidebar, scroll to the Edit Link panel.
    5. In the Type section, click Conditional.
    6. For Link Operation, click Advanced, and then paste the following code into the code evaluation window, altering the code to match your variable's name:

      VAL.toLowerCase().indexOf("dog") > -1

The code in the Return True node converts VAL to lower case, and then looks for the starting position in the search string dog. If it finds dog anywhere in that VAL, it will return true.

Contact supportStill need assistance? Contact Acquia Support