The expression builder node supports a whole host of functions that you can use to perform string, mathematical, conditional, and date operations on values from the workflow context. 

                                                      String Functions

1) charAt(Text text, Number index)


Header

Value

Return Type

String

Syntax

charAt(‘text1’, specified index)

Description

Returns the character at the specified index from the given text1.

Example 

  1. charAt('Freshservice', 0)
    Result: 'F'

  2. charAt('Freshservice', 1)

            Result: 'r'


2) compareTo(Text text1, Text text2)


Header

Value

Return Type

Number

Syntax

compareTo(‘text1’,‘text2’)

Description

Compares text1 and text2  based on their position in the dictionary. This function is case-sensitive.

0, if text1= text2

Positive value, if text1>text2

Negative value,  if text1<text2

Example 


  1. compareTo('aaa', 'aaa')

Result:0

  1. compareTo('aaa', 'AAA')

Result: 32


3) compareToIgnoreCase(Text text1, Text text2)


Header

Value

Return Type

Number

Syntax

compareToIgnoreCase(‘text1’,‘text2’)

Description

Compares text1 and text2 based on their position in the dictionary. This function is not case-sensitive.

0, if text1= text2

Positive value, if text1>text2

Negative value,  if text1<text2

Example 

  1. compareToIgnoreCase('aaa', 'AAA')

Result: 0

  1. compareToIgnoreCase('aaa', 'aaa’')

Result: 0


4)  concat(Text text1, Text text2)


Header

Value

Return Type

String

Syntax

concat(‘text1’, ‘text2’)

Description

Combines text1 and text2.

Example 

  1. concat('aaa', 'AAA')

Result: aaaAAA


5) endsWith(Text text, Text suffix)


Header

Value

Return Type

Boolean (true,false)

Syntax

 endsWith(‘text’, ‘suffix’)

Description

Checks if text ends with the given specific characters.

Example 

  1. endsWith('freshservice', 'vice')

Result: true

  1. endsWith('freshservice', 'abc')
    Result: false


6) equals(Text text1, Text text2)


Header

Value

Return Type

Boolean (true,false)

Syntax

endsWith(‘text1’, ‘ text2’)

Description

Checks if text1 and text2 match. This function is case-sensitive

Example 

  1. equals('freshservice', 'freshservice')

Result: true

  1. equals('freshservice', 'FRESHSERVICE')
    Result: false


7)  equalsIgnoreCase(Text text1, Text text2)


Header

Value

Return Type

Boolean (true,false)

Syntax

equalsIgnoreCase(‘text1’, ‘ text2’)

Description

Checks if text1 and text2 match.This function is not case-sensitive

Example 

  1. equalsIgnoreCase('freshservice', 'freshservice')

Result: true

  1. equalsIgnoreCase('freshservice', 'FRESHSERVICE')

Result: true


8) indexOf(Text text1, Text text2, Number fromIndex)


Header

Value

Return Type

Number

Syntax

indexOf(‘text1’, ‘text2’, fromIndex)

Description

Finds where text2 first occurs within text1 while searching forwards from a specified index.

Example 

  1. indexOf('freshservice', 'es', 0)

Result: 2

  1. indexOf('freshservice', 'er', 3)
    Result: 6


9)  lastIndexOf(Text text1, Text text2, Number fromIndex)


Header

Value

Return Type

Number

Syntax

 lastIndexOf(‘text1’, ‘text2’, fromIndex)

Description

Finds where the text2 last occurs within text1 while searching backwards from a specified index.

Example 

  1. lastIndexOf('freshservice', 'es', 3)

Result: 2

  1. lastIndexOf('freshworks', 'rk', 8)
    Result: 7


10)  length(Text text)


Header

Value

Return Type

Number 

Syntax

length(‘text’)

Description

Returns the number of characters in a given text.

Example 

  1.  length('freshservice')

 Result: 12


11) replace(Text text, Text oldText, Text newText)


Header

Value

Return Type

String

Syntax

 replace(‘text’, ‘oldtext’, ‘newtext’)

Description

Returns a text,replacing all occurrences of oldtext with newtext.

Example 

  1. replace('freshservice', 'service', 'works')
    Result: freshworks


12)  startsWith(Text text, Text prefix, Number fromIndex)


Header

Value

Return Type

Boolean (true, false) 

Syntax

startsWith( ‘text’, ‘prefix’, fromIndex)

Description

Checks if the text starts with a specified prefix,based on the provided fromindex.

Example 

  1.  startsWith('freshservice', 'fres', 0)

 Result: true

   II.       startsWith('freshservice', 'fres', 2)

             Result: false


13)  substring(Text text, Number fromIndex, Number toIndex)


Header

Value

Return Type

String

Syntax

substring( ‘text’, fromIndex, toIndex)

Description

Returns the truncated text starting at the fromIndex and ending at the toIndex


length of the text: endIndex-beginIndex

Example 

  1. substring('freshservice', 0, 1)
    Result: f

  2. substring('freshservice', 0, 3)
    Result: fre



14)  toLowerCase(Text text)


Header

Value

Return Type

String

Syntax

toLowerCase(‘text’)

Description

Converts all of the characters in a text to lowercase.

Example 

  1. toLowerCase('FRESHSERVICE')

Result: freshservice


15) toUpperCase(Text text)


Header

Value

Return Type

String

Syntax

 toUpperCase(‘text’)

Description

Converts all of the characters in a text to upper case.

Example 

  1. toUpperCase('freshservice')
    Result: FRESHSERVICE


16)  trim(Text text)


Header

Value

Return Type

String

Syntax

trim(‘text’)

Description

Removes whitespace from both ends of a text.

Example 

  1. trim('  freshservice  ')
    Result: freshservice

10) regexMatch(Text text, Text pattern)


Header

Value

Return Type

Boolean (true, false)

Syntax

 regexMatch( “text”,  “pattern”)

Description

Checks if the text contains the pattern

Example 

  1.  regexMatch("a", "[amn]?" )
    Result: true

11)  regexReplace(Text text, Text pattern, Text newText)

Header

Value

Return Type

String

Syntax

 regexReplace(“text”, “pattern”, “new text”)

Description

Returns a new string by replacing the pattern in text with newText

Example 

  1. regexReplace("My name is Khan. My name is Bob. My name is Sonoo.", "is", "was" )
    Result: My name was Khan. My name was Bob. My name was Sonoo

                                                         

                                    Mathematical Functions


1) abs(Decimal value)


Header

Value

Return Type

Number

Syntax

abs(value)

Description

Removes the negative sign for a given value and returns an absolute number.

Example 

  1. abs(3.14)

Result: 3.14

  1. abs(-3.14)
    Result: 3.14


 2) acos(Decimal value)


Header

Value

Return Type

Number

Syntax

acos(value)

Description

Returns the arc cosine of the given value.

Returned value range: 0.0 through PI.

Example 

  1. acos(-0.45)
    Result: 2

  2. acos(0.45)
    Result: 1


3) asin(Decimal value)


Header

Value

Return Type

Number

Syntax

asin(value)

Description

Returns the arc sine of the given value.


Returned value range:  -PI/2 through PI/2.

Example 

  1.  asin(1)

 Result:1

  1.  asin(0.789)

 Result: 0


4) atan(Decimal value)


Header

Value

Return Type

Number

Syntax

atan(value)

Description

Returns the arc tangent of the given value.


Returned value range:  -PI/2 through PI/2.

Example 

  1. atan(1)
    Result: 0

  2. atan(1000)

Result: 1


5)  atan2(Decimal x, Decimal y)


Header

Value

Return Type

Number

Syntax

atan2( x, y)

Description

Returns the angle in radians between the X-axis and a line passing though (x,y) and the origin (0,0)

Example 

  1.  atan2(1,1)
     Result: 0.7853981633974483

  2.  atan2(4,3)
     Result: 0.9272952180016122


6) ceil(Decimal value)


Header

Value

Return Type

Number

Syntax

ceil(value)

Description

Rounds up to the smallest integer that is greater than or equal to a given value.

Example 

  1.  ceil(1.583)

 Result: 2

  1.  ceil(-10.328)

 Result: 10

7) cos(Decimal value)

Header

Value

Return Type

Number

Syntax

cos(value)

Description

Returns the trigonometric cosine of an angle.

Example 

  1. cos(1.5707963267948966)

Result:  0

  1. cos(0)
    Result: 1


8) exp(Decimal value)


Header

Value

Return Type

Number

Syntax

exp(value)

Description

Returns Euler's number, e (~2.718) raised to a power.

Example 

  1. exp(10)
    Result: 22026.465794806718

  2. exp(-9)

Result: 0.00012340980408667956


9) floor(Decimal value)


Header

Value

Return Type

Number

Syntax

floor(value)

Description

Rounds up to the greatest integer that is less than or equal to a given value.

Example 

  1. floor(1.583)
    Result: 1

  2. floor(-10.328)
    Result: -11


10) log(Decimal value)


Header

Value

Return Type

Number

Syntax

log(value)

Description

Returns the natural logarithm (base e) of a value.

Example 

  1. log(10.504667)
    Result: 2.351819634603672

  2. log(1)
    Result:0



11max(Decimal value1, Decimal value2)


Header

Value

Return Type

Number

Syntax

max( value1, value2)

Description

Returns the greater of two values.

Example 

  1. max(1, 2)
    Result: 2

  2. max(1000, 23.6)
    Result: 1000



12) min(Decimal value1, Decimal value2)


Header

Value

Return Type

Number

Syntax

min( value1, value2)

Description

Returns the smaller of two values.

Example 

  1. min(1, 2)
    Result: 1

  2. min(1000, 23.6)
    Result: 23.6



13) round(Decimal value, Number decimal place)


Header

Value

Return Type

Number

Syntax

round( value, decimal place)

Description

Rounds a number to the specified decimal places.

Example 

  1.  round(1.3456,3)

Result: 1.346

  1. round(10.456, 0)

Result: 10


14) sin(Decimal value)


Header

Value

Return Type

Number

Syntax

sin(value)

Description

Returns the trigonometric sine of an angle.

Example 

  1. sin(1.5707963267948966)

Result: 1

  1. sin(0)

Result: 0



15) sqrt(Decimal value)


Header

Value

Return Type

Number

Syntax

sqrt(value)

Description

Returns the positive square root of a value.

Example 

  1. sqrt(4)

Result: 2

  1. sqrt(100)
    Result: 10



16) tan(Decimal value)


Header

Value

Return Type

Number

Syntax

tan(value)

Description

Returns the arc tangent of the given value

Returned value range: -PI/2 through PI/2.

Example 

  1.  tan(1.5707963267948966)
    Result: 16331239353195370

  2. tan(0)
    Result: 0


17)  toDegrees(Decimal radians)


Header

Value

Return Type

Number

Syntax

toDegrees(radians)

Description

Converts an angle in radians to the approximately equivalent angle in degrees.

Example 

  1. toDegrees(1.5707963267948966)

Result: 90

  1. toDegrees(1)
    Result: 57.29577951308232


18) toRadians(Decimal degrees)

Header

Value

Return Type

Number

Syntax

toRadians(degrees)

Description

Converts an angle in degrees to the approximate equivalent angle in radians.

Example 

  1. toRadians(90)
    Result: 1.5707963267948966

  2. toRadians(0)
    Result: 0

                        

19)randomNumberOfLength(Decimal value)


Header

Value

Return Type

Number

Syntax

randomNumberOfLength(value)

Description

Returns random number of the specified length.

Example 

  1. randomNumberOfLength(3)
    Result: 842

  2. randomNumberOfLength(4)
    Result: 1729

                                               

                                          Conditional Functions


  1. if(conditional_expression, expression_if_true , expression_if_false)



Header

Value

Return Type

string/boolean/number

Syntax

if(conditional_epression, expression_if_true , expression_if_false)

Description

  • conditional_expression - An expression that represents some logical value( i.e.TRUE or FALSE) or boolean value.

  • expression_if_true -  executes conditions set for True if criteria matches

  • expression_if_false - executes condition set for False if criteria fails.

  • The expression_if_true, expression_if_false and return_type should be of the same type.


Example 

  1. if (2>1, "greater", "smaller")

Result: greater



                                Date Functions


  1.  addDays(date, number of days)


Header

Value

Return Type

Date/Date-time

Syntax

addDays(“date/date-time”, number of days)


Only ISO formatted date/date-time placeholders are accepted. 

date - ( yyyy-mm-dd )

date-time - ( ( yyyy-mm-ddThh:mm:ssZ ))

Description

Adds the specified number of days to the given date.


Negative days value will subtract the number of days from the given date. 

Example 

  1. addDays(“2019-12-31”,12)

            Result: 2020-01-12
   II.     addDays(“2019-12-31T00:45:34Z”,12)

      Result: 2020-01-12T00:45:34Z



  2.  addMonths(date, months)


Header

Value

Return Type

Date/Date-time

Syntax

addMonths(date/date-time, number of months)

date - ( yyyy-mm-dd )

date-time - ( ( yyyy-mm-ddThh:mm:ssZ ))

Description

Adds the specified number of months to the given date.

Negative months value will subtract the number of months from the given date.

Example 

  1. addMonths(“2019-12-31”,19)

            Result: 2021-07-31

  1. addMonths(“2019-12-31T00:45:34Z”,19)

Result: 2021-07-31T00:45:34Z

 

 3.  addYears(date, years)


Header

Value

Return Type

Date/Date-time

Syntax

addYears(date/date-time, number of years)

date - ( yyyy-mm-dd )

date-time - ( ( yyyy-mm-ddThh:mm:ssZ ))

Description

Adds the specified number of years to the given date.

Negative years value will subtract the number of years from the given date.

Example 

  1. addYears(“2019-12-31”,4)

            Result: 2023-12-31

  1. addYears(“2019-12-31T00:45:34Z”,-4)

Result: 2015-12-31T00:45:34Z


 4.  date(year,month,day)


Header

Value

Return Type

Date

Syntax

date(year,month,day)

Description

Returns the value in date format (yyyy-mm-dd).

Example 

  1. date(2019,12,31)
    Result: 2019-12-31


5. dateTime(year,month,day,hour.min,sec,timezone)


Header

Value

Return Type

Date-time

Syntax

date(year,month,day,hour,min,sec,timezone)

Description

Returns the value in date-time format (yyyy-mm-ddThh:mm:ss+timezone).

Example 

  1. date(2019,12,3,23,1,50,”Asia/Kolkata”)
    Result: 2019-12-31T23:01:50+05:30



6. day(date/date-time)



Header

Value

Return Type

Number

Syntax

day(date/date-time)

date - ( yyyy-mm-dd )
date-time - ( ( yyyy-mm-ddThh:mm:ssZ )

Description

Extracts the day from the given date expression.

Example 

  1. day(“ 2019-12-31”)
    Result: 31


7. month(date/date-time)


Header

Value

Return Type

Number

Syntax

month(date/date-time)

date - ( yyyy-mm-dd )
date-time - ( yyyy-mm-ddThh:mm:ssZ )

Description

Extracts the month from the given date expression.

Example 

  1. month(“2019-12-31T00:45:34Z”)
    Result: 12


8. now(timezone)


Header

Value

Return Type

Date-time

Syntax

now(timezone)

Description

Returns the current time for the given timezone.

Example 

  1. now(“Asia/Kolkata”)
    Result: 2019-08-06T00:45:34+05:30


9. today(timezone)



Header

Value

Return Type

Date-time

Syntax

today(timezone)

Description

Returns the current date for the given timezone.

Example 

  1. today(“Asia/Kolkata”)
    Result: 2019-08-06



10. weekday(date)



Header

Value

Return Type

Date-time

Syntax

weekday(date)

Description

Returns the weekday number for the date given.

Sunday-1

Saturday-7

Example 

  1. weekday(“2019-12-31”)
    Result: 3


11. year(date)


Header

Value

Return Type

Number

Syntax

year(date/date-time)


date -(yyyy-mm-dd)
date-time- ( yyyy-mm-ddThh:mm:ssZ )

Description

Extracts the year from the given date format.

Example 

  1. year(“2019-12-31”)
    Result: 2019

  2. year(“2019-12-31T00:45:34Z”)
    Result: 2019


12. dateTimeValue(date,timezone)


Header

Value

Return Type

Date-time

Syntax

dateTimeValue(date,timezone)

Description

Returns the value in date-time format ( yyyy-mm-ddThh:mm:ssZ )

Example 

  1. dateTimeValue(“2019-12-31”,”Asia/Calcutta”)
    Result: 2019-12-31T00:00:00+05:30


13. dateValue(datetime)


Header

Value

Return Type

date

Syntax

dateValue(datetime)

Description

Returns the value in date format (yyyy-mm-dd).

Example 

  1. dateValue(“1993-07-13T00:00:00+09:00”)
    Result: 1993-07-13


14. addhours


Header

Value

Return Type

Date/Date-time

Syntax

addHours(date/date-time, hours)

date - ( yyyy-mm-dd )

date-time - ( ( yyyy-mm-ddThh:mm:ssZ))

Description

Adds the specified number of hours to the given date.


Negative days value will subtract the number of days from the given date. 

Example 

addhours(“2019-12-31”,28)
Result: 2020-01-01

addhours ("2019-12-31T00:45:34Z",12)
Result: "2019-12-31T12:45:34Z"


15. diffInHours


Header

Value

Return Type

Number/Decimal

Syntax

diffInHours( start_date, end_date )

date - ( yyyy-mm-dd )

date-time - ( ( yyyy-mm-ddThh:mm:ssZ))

Description

Returns difference in hours between the start date and end date.


If the end date occurs before the start date the result will be a negative number.

Example 

  1. diffInHours(“1993-07-13”,”1993-07-15)
    Result: 48

  2. diffInHours("1993-07-13T11:45:34Z","1993-07-15")
    Result: 36


16. diffInDays


Header

Value

Return Type

Number/Decimal

Syntax

diffInDays( start_date, end_date )

date - ( yyyy-mm-dd )

date-time - ( ( yyyy-mm-ddThh:mm:ssZ))

Description

Returns difference in days between the start date and end date.


If the end date occurs before the start date the result will be a negative number.

Example 

  1. diffInDays(“1993-07-13”,”1993-07-15)
    Result: 2

  2. diffInDays("1993-07-13T11:45:34Z","1993-07-15")
    Result: 1


16. diffInWeeks


Header

Value

Return Type

Number/Decimal

Syntax

diffInWeeks( start_date, end_date )


date - ( yyyy-mm-dd )

date-time - ( ( yyyy-mm-ddThh:mm:ssZ))

Description

Returns difference in weeks between the start date and end date.


If the end date occurs before the start date the result will be a negative number.

Example 

  1. diffInWeeks("1993-07-13T11:45:34Z","1993-07-06T11:45:34Z")
    Result: -1