Supported Functions in Advanced Condition Builder

This article explains the various functions available in SpotDraft's advanced conditions builder for setting up approvals. Understanding the behavior and exceptions of these functions will help you create more precise and effective approval workflows.

List of Supported Functions

Equals (value1, value2):

  • Purpose: This function outputs TRUE if value 1 equals value 2; otherwise, the output is FALSE.
  • Supported Inputs: number, currency, duration, dropdown, short text
  • Output Type: TRUE, FALSE
  • Example:
    • Equals( Currency (100, "USD"), Currency (40, "USD")) = FALSE
    • Equals( Duration(4, "MONTHS"), Duration(4, "MONTHS")) = TRUE
    • Equals( 50, 60) = FALSE
    • Equals( “SpotDraft”, “SpotDraft”) = TRUE
    • Equals( “SPOTDRAFT”, “spotdraft”) = FALSE

GreaterThanOrEqual (value1, value2):

  • Purpose: This function outputs TRUE if value 1 is greater than or equal to value 2; otherwise, the output is FALSE.
  • Supported Inputs: number, currency, duration
  • Output Type: TRUE, FALSE
  • Example:
    • GreaterThanOrEqual( Currency (100, "USD"), Currency (40, "USD")) = TRUE
    • GreaterThanOrEqual( Duration(4, "MONTHS"), Duration(4, "MONTHS")) = TRUE
    • GreaterThanOrEqual( 50, 60) = FALSE

GreaterThan (value1, value2):

  • Purpose: This function outputs TRUE if value 1 is greater than value 2; otherwise, the output is FALSE.
  • Supported Inputs: number, currency, duration
  • Output Type: TRUE, FALSE
  • Example:
    • GreaterThan( Currency (100, "USD"), Currency (40, "USD")) = TRUE
    • GreaterThan( Duration(4, "MONTHS"), Duration(4, "MONTHS")) = FALSE
    • GreaterThan( 50, 60) = FALSE

LessThanOrEqual (value1, value2):

  • Purpose: This function outputs TRUE if value 1 is less than or equal to value 2; otherwise, the output is FALSE.
  • Supported Inputs: number, currency, duration
  • Output Type: TRUE, FALSE
  • Example:
    • LessThanOrEqual( Currency (100, "USD"), Currency (40, "USD")) = FALSE
    • LessThanOrEqual( Duration(4, "MONTHS"), Duration(4, "MONTHS")) = TRUE
    • LessThanOrEqual( 50, 60) = TRUE

LessThan (value1, value2):

  • Purpose: This function outputs TRUE if value 1 is less than value 2; otherwise, the output is FALSE.
  • Supported Inputs: number, currency, duration
  • Output Type: TRUE, FALSE
  • Example:
    • LessThan( Currency (100, "USD"), Currency (40, "USD")) = FALSE
    • LessThan( Duration(4, "MONTHS"), Duration(4, "MONTHS")) = FALSE
    • LessThan( 50, 60) = TRUE

Not (value 1):

  • Purpose: This function outputs TRUE if value 1 is FALSE; otherwise, the output is FALSE.
  • Supported Inputs: TRUE, FALSE
  • Output Type: TRUE, FALSE
  • Example:
    • Not(Equals( Duration(4, "MONTHS"), Duration(4, "MONTHS"))) = FALSE

Empty (value 1):

  • Purpose: This function outputs TRUE if value 1 is Empty; otherwise, the output is FALSE.
  • Supported Inputs: number, currency, duration, dropdown, short text
  • Output Type: TRUE, FALSE
  • Example:
    • Empty(Duration(4, “MONTHS”) = FALSE
    • Empty( "" ) = TRUE

Contains (value 1, value 2):

  • Purpose: This function outputs TRUE if value 1 contains value 2; otherwise, the output is FALSE.
  • Supported Inputs: Dropdown, Multiple dropdowns
  • Output Type: TRUE, FALSE
  • Example:
    • License_Options is a dropdown variable that has 2 values - "2 licenses", "4 licenses"
      • Contains( License_Options, "3 licenses") = FALSE
    • Allowed_Users is a string variable - "60 users for 3 months"
      • Contains( Allowed_Users, "60 users") = TRUE

Duration (value, unit):

  • Purpose: This function outputs a custom duration object. You can use it to compare duration variables with a specific value.
  • Supported Inputs:
    • Value: Number
    • Units: "DAYS", "WEEKS", "MONTHS", "YEARS"
  • Output Type: Custom duration object
  • Example:
    • Duration( 4, “MONTHS”) = 4 MONTHS
    • Duration( 3, “DAYS”) = 3 DAYS
    • Duration( 1, “YEARS”) = 1 YEAR
    • Duration( 5, “WEEKS”) = 5 WEEKS
  • Conversion Matrix:
    • 1 week = 7 days
    • 1 month = 30 days
    • 1 year = 365 days

Currency (value, unit):

  • Purpose: This function outputs a custom currency object. You can use it to compare currency variables with a specific value.
  • Supported Inputs:
    • Value: Number
    • Unit: "USD", "INR", "GBP", "EUR"......
  • Output Type: Custom currency object
  • Example:
    • Currency( 120, “USD”) = 120 USD
    • Currency( 230, “EUR”) = 230 EUR
    • Currency( 320, “INR”) = 320 INR
    • Currency( 10, “GBP”) = 10 GBP

Important Notes

  • Supported Inputs: The functions are designed to work with only specific variable types as inputs. Ensure that the variables you are using in the formula match the supported input types for the function.
  • Capitalization: All the currency & duration units must be entered in capital case.
    • (e.g., For currency -  "USD", "INR")
    • (e.g., For duration - "DAYS", "MONTHS")
  • Name Spacing: When using variables, it is also necessary to define their source. The source is defined as a prefix followed by a dot (.)
    • When referencing variables from intake forms or questionnaires, use the "intake." prefix. e.g. intake.deal_value
    • For contract entity variables, use the "entity." prefix. e.g., entity.reference_id

Exception Scenarios

  • Function Arguments: If you pass arguments of different data types to a function that supports multiple arguments, the function will always evaluate to FALSE. e.g.
    • LessThan( number, currency) = FALSE
    • GreaterThanOrEqual ( number, short text) = FALSE
  • Currency Mismatch: When using functions that take two currency values as input, if the currencies do not match, the function will evaluate to FALSE.
    • GreaterThan( Currency( 100, “USD”), Currency( 100, “INR”) = FALSE
    • LessThan( Currency( 100, “USD”), Currency( 100, “INR”) = FALSE
    • Equals( Currency( 100, “USD”), Currency( 100, “INR”) = FALSE

Common Errors and Solutions

  • Invalid Function Name:
    • "Expecting: one of these possible Token sequences: ....."
    • This error could occur
      • when you try to use a function name that SpotDraft doesn't recognize.
      • when you have add an AND/OR operator in the formula but not added another function following the AND/OR operator
    • Solution:
      • Carefully check the function name you've typed, or rewrite the function by using the autocomplete feature to see suggestions of valid functions.
      • Check if there are any AND/OR operators and if they are followed by a valid function
  • Extra Double Quotes:
    • "Expecting token of type --> RPAREN <--- but found --> "XYZ" <---" 
    • This error could occur when you use extra double quotes while passing a text string as an input to the function.
    • Solution: Check for the extra double quotes & remove them wherever incorrect. Text strings within the function should be enclosed in a single set of double quotes.
  • Missing Comma Separator:
    • "Expecting token of type --> Comma <--- but found --> ")" <---" 
    • This error could occur when you need to pass multiple arguments to a function, but you only pass 1 or forget to separate them with a comma.
    • Solution: Insert a comma (,) after each argument in the function.

Was this article helpful?

0 out of 0 found this helpful