Last updated: 2025-08-14
Source: https://support.freshservice.com/support/solutions/articles/50000004102-functions-in-expression-builder-node
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’, specifiedindex) |
| Description | Returns the character at the specified index from the given text1. |
| Example | 1. charAt('Freshservice', 0)<br> <br> Result: 'F'<br> <br>2. charAt('Freshservice', 1)<br> <br> 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.<br>0, if text1= text2<br>Positive value, if text1>text2<br>Negative value, if text1<text2 |
| Example | 1. compareTo('aaa', 'aaa')<br> <br>Result:0<br>2. compareTo('aaa', 'AAA')<br> <br>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.<br>0, if text1= text2<br>Positive value, if text1>text2<br>Negative value, if text1<text2 |
| Example | 1. compareToIgnoreCase('aaa', 'AAA')<br> <br>Result: 0<br>2. compareToIgnoreCase('aaa', 'aaa’')<br> <br>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')<br> <br>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')<br> <br>Result: true<br>2. endsWith('freshservice', 'abc')<br> <br> 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')<br> <br>Result: true<br>2. equals('freshservice', 'FRESHSERVICE')<br> <br> 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')<br> <br>Result: true<br>2. equalsIgnoreCase('freshservice', 'FRESHSERVICE')<br> <br>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)<br> <br>Result: 2<br>2. indexOf('freshservice', 'er', 3)<br> <br> 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)<br> <br>Result: 2<br>2. lastIndexOf('freshworks', 'rk', 8)<br> <br> 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')<br> <br>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')<br> <br> 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)<br> <br>Result: true<br>II. startsWith('freshservice', 'fres', 2)<br> 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<br>length of the text: endIndex-beginIndex |
| Example | 1. substring('freshservice', 0, 1)<br> <br> Result: f<br> <br>2. substring('freshservice', 0, 3)<br> <br> 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')<br> <br>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')<br> <br> 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 ')<br> <br> Result: freshservice |
17) 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\]?" )<br> <br> Result: true |
18) 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" )<br> <br> Result: My name was Khan. My name was Bob. My name was Sonoo |
19) intOf('text1')
| |
|---|
| Header | Value |
| Return Type | Integer |
| Syntax | intOf(‘text1’) |
| Description | Returns the integer value for the string.<br>Return Type: Integer<br>Syntax<br>IntOf ('value 1')<br>Note: The value 1 here is a string. |
| Example | IntOf('120')<br>Result will be 120 |
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)<br> <br>Result: 3.14<br>2. abs(-3.14)<br> <br> Result: 3.14 |
2) acos(Decimal value)
| |
|---|
| Header | Value |
| Return Type | Number |
| Syntax | acos(value) |
| Description | Returns the arc cosine of the given value.<br>Returned value range: 0.0 through PI. |
| Example | 1. acos(-0.45)<br> <br> Result: 2<br> <br>2. acos(0.45)<br> <br> Result: 1 |
3) asin(Decimal value)
| |
|---|
| Header | Value |
| Return Type | Number |
| Syntax | asin(value) |
| Description | Returns the arc sine of the given value.<br>Returned value range: -PI/2 through PI/2. |
| Example | 1. asin(1)<br> <br>Result:1<br>2. asin(0.789)<br> <br>Result: 0 |
4) atan(Decimal value)
| |
|---|
| Header | Value |
| Return Type | Number |
| Syntax | atan(value) |
| Description | Returns the arc tangent of the given value.<br>Returned value range: -PI/2 through PI/2. |
| Example | 1. atan(1)<br> <br> Result: 0<br> <br>2. atan(1000)<br> <br>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)<br> <br> Result: 0.7853981633974483<br> <br>2. atan2(4,3)<br> <br> 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)<br> <br>Result: 2<br>2. ceil(-10.328)<br> <br>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)<br> <br>Result: 0<br>2. cos(0)<br> <br> 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)<br> <br> Result: 22026.465794806718<br> <br>2. exp(-9)<br> <br>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)<br> <br> Result: 1<br> <br>2. floor(-10.328)<br> <br> 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)<br> <br> Result: 2.351819634603672<br> <br>2. log(1)<br> <br> Result:0 |
11) max(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)<br> <br> Result: 2<br> <br>2. max(1000, 23.6)<br> <br> 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)<br> <br> Result: 1<br> <br>2. min(1000, 23.6)<br> <br> 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)<br> <br>Result: 1.346<br>2. round(10.456, 0)<br> <br>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)<br> <br>Result: 1<br>2. sin(0)<br> <br>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)<br> <br>Result: 2<br>2. sqrt(100)<br> <br> Result: 10 |
16) tan(Decimal value)
| |
|---|
| Header | Value |
| Return Type | Number |
| Syntax | tan(value) |
| Description | Returns the arc tangent of the given value<br>Returned value range: -PI/2 through PI/2. |
| Example | 1. tan(1.5707963267948966)<br> <br> Result: 16331239353195370<br> <br>2. tan(0)<br> <br> 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)<br> <br>Result: 90<br>2. toDegrees(1)<br> <br> 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)<br> <br> Result: 1.5707963267948966<br> <br>2. toRadians(0)<br> <br> 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)<br> <br> Result: 842<br> <br>2. randomNumberOfLength(4)<br> <br> 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.<br> <br>- expression\_if\_true \- executes conditions set for True if criteria matches<br> <br>- expression\_if\_false - executes condition set for False if criteria fails.<br> <br>- The expression\_if\_true, expression\_if\_false and return\_type should be of the same type. |
| Example | 1. if (2>1, "greater", "smaller")<br> <br>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)<br>Only ISO formatteddate/date-time placeholders are accepted. <br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ )) |
| Description | Adds the specified number of days to the given date.<br>Negative days value will subtract the number of days from the given date. |
| Example | 1. addDays(“2019-12-31”,12)<br> <br> Result: 2020-01-12<br>II. addDays(“2019-12-31T00:45:34Z”,12)<br>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)<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ )) |
| Description | Adds the specified number of months to the given date.<br>Negative months value will subtract the number of months from the given date. |
| Example | 1. addMonths(“2019-12-31”,19)<br> <br> Result: 2021-07-31<br>2. addMonths(“2019-12-31T00:45:34Z”,19)<br> <br>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)<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ )) |
| Description | Adds the specified number of years to the given date.<br>Negative years value will subtract the number of years from the given date. |
| Example | 1. addYears(“2019-12-31”,4)<br> <br> Result: 2023-12-31<br>2. addYears(“2019-12-31T00:45:34Z”,-4)<br> <br>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)<br> <br> 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”)<br> <br> Result: 2019-12-31T23:01:50+05:30 |
6\. day(date/date-time)
| |
|---|
| Header | Value |
| Return Type | Number |
| Syntax | day(date/date-time)<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ ) |
| Description | Extracts the day from the given date expression. |
| Example | 1. day(“ 2019-12-31”)<br> <br> Result: 31 |
7\. month(date/date-time)
| |
|---|
| Header | Value |
| Return Type | Number |
| Syntax | month(date/date-time)<br>date - ( yyyy-mm-dd )<br>date-time - ( yyyy-mm-ddThh:mm:ssZ ) |
| Description | Extracts the month from the given date expression. |
| Example | 1. month(“2019-12-31T00:45:34Z”)<br> <br> 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”)<br> <br> 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”)<br> <br> 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.<br>Sunday-1<br>Saturday-7 |
| Example | 1. weekday(“2019-12-31”)<br> <br> Result: 3 |
11\. year(date)
| |
|---|
| Header | Value |
| Return Type | Number |
| Syntax | year(date/date-time)<br>date -(yyyy-mm-dd)<br>date-time- ( yyyy-mm-ddThh:mm:ssZ ) |
| Description | Extracts the year from the given date format. |
| Example | 1. year(“2019-12-31”)<br> <br> Result: 2019<br> <br>2. year(“2019-12-31T00:45:34Z”)<br> <br> 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 | Refer to the following table, which provides an example on various scenarios, inputs, and behaviour. |
_Note: These changes are applicable from August 2025._
| | | | |
|---|
| Scenario | Input - dateTime | Input - timezone | Previous Behaviour | New Behaviour (from Aug 2025) |
| 1\. Date input | "2025-06-02" | "Asia/Kolkata" | Interprets as 2025-06-02T00:00:00 in Asia/Kolkata → 2025-06-02T00:00:00+05:30 | Treats date as 2025-06-02T00:00:00Z → Converts to Asia/Kolkata → 2025-06-02T05:30:00+05:30 |
| 2\. DateTime input with Z (UTC) | "2025-06-02T00:00:00Z" | "Asia/Kolkata" | Throws error 1505 – invalid operand | Converts UTC to zone → 2025-06-02T05:30:00+05:30 |
| 3\. DateTime input with Z (UTC) | "2025-06-02T12:24:30Z" | "UTC" | Throws error 1505 – invalid operand | Returns input as-is → 2025-06-02T12:24:30Z |
| 4\. DateTime input with offset | "2025-06-02T00:00:00+05:30" | "Australia/Sydney" | Throws error 1505 – invalid operand | Convert from input offset → UTC → target zone → 2025-06-02T04:30:00+10:00 |
| 5\. DateTime input with offset | "2025-06-02T12:00:00+00:00" | "UTC" | Throws error 1505 – invalid operand | Same time in UTC → 2025-06-02T12:00:00Z |
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”)<br> <br> Result: 1993-07-13 |
14\. addhours
| |
|---|
| Header | Value |
| Return Type | Date/Date-time |
| Syntax | addHours(date/date-time, hours)<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ)) |
| Description | Adds the specified number of hours to the given date.<br>Negative days value will subtract the number of days from the given date. |
| Example | addhours(“2019-12-31”,28)<br>Result: 2020-01-01<br>addhours ("2019-12-31T00:45:34Z",12)<br>Result: "2019-12-31T12:45:34Z" |
15\. diffInHours
| |
|---|
| Header | Value |
| Return Type | Number/Decimal |
| Syntax | diffInHours( start\_date, end\_date )<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ)) |
| Description | Returns difference in hours between the start date and end date.<br>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”)<br> <br> Result: 48<br> <br>2. diffInHours("1993-07-13T11:45:34Z","1993-07-15")<br> <br> Result: 36 |
16\. diffInDays
| |
|---|
| Header | Value |
| Return Type | Number/Decimal |
| Syntax | diffInDays( start\_date, end\_date )<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ)) |
| Description | Returns difference in days between the start date and end date.<br>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”)<br> <br> Result: 2<br> <br>2. diffInDays("1993-07-13T11:45:34Z","1993-07-15")<br> <br> Result: 1 |
17\. diffInWeeks
| |
|---|
| Header | Value |
| Return Type | Number/Decimal |
| Syntax | diffInWeeks( start\_date, end\_date )<br>date - ( yyyy-mm-dd )<br>date-time - ( ( yyyy-mm-ddThh:mm:ssZ)) |
| Description | Returns difference in weeks between the start date and end date.<br>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")<br> <br> Result: -1 |
``` Note: We recommend verifying the syntax in the expression node to ensure smooth workflow automation execution. ```