Built-in Functions

A function is a set of code, that takes a finite number of input and optionally returns a value.

 String functions

Functions that operate on string expression are classified as string functions, they include functions for finding the length of a given text, remove certain words from a text etc.

In all the given functions, the original string is not changed by the functions, whereas only the return value is affected by these functions.

OperatoFormat**Description
+<string1> + <string2>Concatenate two strings
contains(<string>)<string1>.contains(<string2>)Returns :boolean
Returns true if string2 is a substring of string1
endsWith(<string>)<string1>.endsWith(<string2>)Returns :boolean
Returns true if string1 ends with string2
startsWith(<string>)<string1>.startsWith(<string2>)Returns :boolean
Returns true if string1 starts with string2
remove(<string>)<string>.remove(<substring>)Eliminate the substring
from the given string.
removeFirstOccurence()<string>.removeFirst
Occurence(<substring>)
Eliminate the first occurence of the substring
from the given string.
removeLastOccurence()<string>.removeLast
Occurence(<substring>)
Eliminate the last occurence of the substring
from the given string.
getSuffix()<string>.getSuffix(<substring>)Get the string after the specified substring.
getPrefix()<string>.getPrefix(<substring>)Get the string before the specified substring.
toUpperCase()<string>.toUpperCase()Convert the string to uppercase.
toLowerCase()<string>.toLowerCase()Convert the string to lowercase.
getAlphaNumeric()<string>.getAlphaNumeric()Retain only the alphanumeric present in the
specified string.
getAlpha()<string>.getAlpha()Retain only the alphabets present in the
specified string.
removeAllAlphaNumeric()<string>.removeAll
AlphaNumeric()
Remove all the alphanumeric present in the
specified string.
removeAllAlpha()<string>.removeAllAlpha()Remove all the alphabets present in the
specified string.
length()<string>.length()Get the length of the given string.
getOccurenceCount()<string>.getOccurence
Count(<substring>)
Gets the number of times a substring is
present in the given string.
indexOf()<string>.indexOf(<substring>)Gets the index of the first occurence of
the substring in the given string.
lastIndexOf()<string>.lastIndexOf(<substring>)Gets the index of the last occurence of the
substring in the given string.
substring(<s.index>, <e.index>)<string1>.substring(<
s.index>, <e.index>)
Returns the substring from the specified
startindex to the endindex. The startindex
and endindex values are base zero specifications
(i.e) you reference the positions within the main
string starting with zero , the second position
in the string is 1, the third is 2 etc..

- startindex value is the position of the first
character in the main String to be extracted to the
SubString.

- endindex value is the position of character in the
main String where you stop extracting to the SubString
and NOT the position of the last character in the main
string to be extracted to the SubString.
trim()<string>.trim()Removes any leading and trailing space
from a string
equalsIgnoreCase
(<string>)
<string1>.equalsIgnoreCase
<string2>
Returns true if <string1> equals <string2>
toString()<expression>.toStringConverts any type of expression to string.
Refer  the behavior of toString() when applied to date/time
value.
matches()<string expression>.matches
(<regular expression>)
returns true if the given string
matches regular expression given as argument.
Ex:
  1. phone = "(123) 456 7890";
  2. if(phone.matches("^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$") == false)
  3. {
  4. Info "Please enter a valid Phone format";
  5. }
 replaceAll(searchString,
replacementString, [escapeRegEx])
<String>.replaceAll
(<searchString>,
<replacementString>
,false)
Replaces all occurrence of the string that matches the given <searchString> expression with the given <replacementString>.

Examples:


searchVariable="Jack and Jill went up the hill to fetch
a pail of water";
searchString="Jack";
replacementString="Bill";
resultVariable = sourceVariable.
ReplaceAll(searchString,replacementString);
//returns "Bill and Jill went up the hill
to fetch a pail of water"


input.Address = "Suite 123, 4523 Yonge
Street, Toronto";
input.Address = input.Address.replaceAll("23","9945");
//returns "Suite 19945, 459945 Yonge Street, Toronto"

By default, the replaceAll() function
supports regular expression (i.e) it will not
find and replace the special characters like $,* etc.,
in the source string.

The parameter [escapeRegEx] is an optional
boolean parameter provided to specify if the regular
expression is to be supported or escaped by Zoho Creator,
while executing the replaceAll() function.
  • The value true denotes escaping the regular
    expression support on replace functions.
  • The value false denotes supporting regular expression
    on replace functions. By default, the value is
    taken as "false".
Note: If the value for escapeRegEx parameter is not
specified, the value we will take as " false".
i.e By default, regular expression is supported on replace
functions. For example, the following two functions will
perform the same operation:

replaceAll("OnlineLine DB","Creator",false)
replaceAll("OnlineLine DB","Creator")

replaceFirst(searchString,
replacementString,[escapeRegEx])
<String>.replaceFirst
(<searchString>,
<replacementString>,
false)
Replaces the first occurrence of the string
that matches the given <searchString>
expression with the given <replacementString>.

By default, the replaceFirst function
supports regular expression (i.e) it will not
find and replace the special characters like $,* etc., in the
source string.

The parameter [escapeRegEx] is an optional boolean parameter provided to specify if the regular
expression is to be supported or escaped by Zoho Creator,
while executing the replaceFirst() function.
  • The value true denotes escaping the regular expression
    support on replace functions.
  • The value false denotes supporting regular expression
    on replace functions. By default, the value is taken as "false".
Note: If the value for escapeRegEx parameter is not
specified, the value we will take as " false".

Note:

  • In the above table, <string>,<string1>,<string2>, <substring> are all <string expression>
  •  Behavior of toString()when applied to datetime value:
    • <date/datetime>.toString() function on date/datetime will output date string in the format specified in the application setting.
    • If you want to override it, you can use <date/datetime>.toString("date format as string"). eg. toString("dd-MM-yyyy")
    • If you wish convert to string in different timezone, you can use <date/datetime>.toString("date format as string","<Time Zoho>"). eg. toString("dd-MM-yyyy","Asia/Calcutta")
  • The Date and Time pattern strings are mentioned below,
    • Date - dd
    • Month - MM (or) MMM (or) MMMM
    • Year - yy (or) yyyy
    • 12 hour format - hh
    • 24 hour format - HH
    • minute - mm
    • second - ss
    • AM/PM marker - a

 Numeric Functions

Functions that operate on numeric values are classified as numeric functions:

In all the given functions, the original number is not changed by the functions, whereas only the return value is affected by these functions.

OperatorFormatDescription
sin()Format :<numeric>.sin()
Returns :numeric
Returns the trigonometric sine of the given angle
sqrt()Format :<numeric>.sqrt()
Returns :numeric
Returns the correctly rounded positive square root of the given value
tan()Format :<numeric>.tan()
Returns :numeric
Returns the trigonometric tangent of an angle.
toDecimal()Format :<expression>.toDecimal()
Returns :Decimal
Returns Decimal from given expression.
toLong()Format :<expression>.toLong()
Returns :numeric
Returns Long from given expression. The hexadecimal string should be preceded by '0x'. Eg "0x1F".toLong() returns hexadecimal value of '1F'.
round()Format:<numeric>.round(<precision-numeric>)Returns the number after rounding off to the specified number of digits.
log()Format:<numeric>.log()Returns the logarithmic value (LogeN) of the specified number.

 Boolean string functions

These functions operate on two string expression and return a boolean expression.

OperatorUsageReturns true when
==<string1> == <string2>two string expressions are equal
contains()<string1>.contains(<string2>)string2 is a substring of string1
startsWith()<string1>.startsWith(<string2>)string1 starts with string2
endsWith()<string1>.endsWith(<string2>)string1 ends with string2

 Date Functions

OperatorFormatReturns
getDay()<date>.getDay()
where, <date> is a form field of type "date"
returns a number in the range (1 - 31), representing the number of the day of the month on which the date occurs.
getMonth()<date>.getMonth()
where, <date> is a form field of type "date"
returns a number in the range (1 -12), representing the number of the month of the year, on which the date occurs
getYear()<date>.getYear()
where, <date> is a form field of type "date"
returns a number representing the year of the date.
getWeekOfYear()<date>.getWeekOfYear()
where, <date> is a form field of type "date"
returns a number in the range (1 - 52), representing the number of the week in the year. For example, "16/1/2007" returns 3.
getDayOfWeek()<date>.getDayOfWeek()
where, <date> is a form field of type "date"
returns a number in the range (1 - 7), representing the number of the day of the week, that date falls. The number "1" represents Sunday, "2" represents Monday and so on.
getDayOfYear()<date>.getDayOfYear()
where, <date> is a form field of type "date"
return a number in the range 1-365, representing the number of the day of the year that date falls.
addDay()<date/time>.addDay(<numeric>)Returns a Date, after adding the specified number of day(s)
addMonth()<date/time>.addMonth(<numeric>)Returns a Date, after adding the specified number of month(s)
addWeek()<date/time>.addWeek (<numeric>)Returns a Date, after adding the specified number of week(s).
addYear()<date/time>.addYear(<numeric>)Returns a Date,after adding the specified number of year(s).
subDay()<date/time>.subDay(<numeric>)Returns a Date, after subtracting the specified number of day(s).
subMonth()<date/time>.subMonth(<numeric>)Returns a Date, after subtracting the specified number of ,month(s).
subWeek()<date/time>.subWeek(<numeric>)Returns a Date, after subtracting the specified number of week(s).
subYear()<date/time>.subYear(<numeric>)Returns a Date, after subtracting the specified number of year(s)
toDate()<string>.toDate()<string>.toDate() function will always parse the input string using the format specified in the application setting and will throw an error if it cannot convert the string to date. If you want to override it, you can use <string>.toDate("date format as string").
eg: toDate("dd-MM-yyyy")
toTime()<string>.toTime() <string>.toTime() function will always parse the input string using the format specified in the application setting and will throw an error if it cannot convert the string to date-time.
endsIf you want to override it, you can use <string>.toTime("date format as string"). eg: toTime("dd-MM-yyyy")

 Time functions

OperatorFormatReturns
addHour()<date-time>.addHour(<numeric>)Returns a Date, after adding the specified number of hour(s).
addMinutes()<date-time>.addMinutes(<numeric>)Returns a Date, after adding the specified number of minute(s).
addSeconds()<date-time>.addSeconds(<numeric>)Returns a Date, after adding the specified number of second(s).
getHour()<date-time>.getHour()Returns the hour of the day
getMinutes()<date-time>.getMinutes()Returns the minutes of the hour
getSeconds()<date-time>.getSeconds()Returns the Seconds of the minute
subHour()<date-time>.subHour(<numeric>)Returns a Date, after subtracting the specified number of hour(s).
subMinutes()<date-time>.subMinutes(<numeric>)Returns a Date, after subtracting the specified number of minute(s).
subSeconds()<date-time>.subSeconds(<numeric>)Returns a Date, after subtracting the specified number of second(s).

 List Functions

OperatorFormatReturns
contains()<list>.contains(<element>)Returns :boolean
returns 'true' if the element is present in the list
get()<list>.get(<index>)Returns: element
returns the element at the specified postion (first element will be at index '0')
indexOf()<list>.indexOf(<element>)Returns :numeric
returns the position of the given element in list (first element's position is '0')
lastIndexOf()<list>.lastIndexOf(<element>)Returns the position of the last occurence of the element in the list.
remove()<list>.remove(<index>)remove and return the element at the specified index (first element's index is '0')
sort()<list>.sort(<optional boolean>)Returns: list
returns the list in the sorted order. The optional boolean specifies ascending(true)/descending(false)
size()<list>.size()Returns the number of elements in the list.
isempty()<list>.isempty()Returns :boolean
returns 'true' if the list is empty (else 'false')
sublist()<list>.sublist(<start index>,<optional endIndex>)Returns: list
returns the sublist of the given list starting from the given start index to the specied end index (to the end of the list, if endIndex not given)
toList()<string>.toList(<optional separator>)Returns: list
converts the string to list using the given separator(default separator is ',' (comma))
{}{<optional comma separated elements>}Returns: list
Create a list with the given elements. Creates empty list if no element is given.
List()List()Returns: list
Create an empty list.
List:String()List:String()Returns: list
Create an empty string list. This list can hold only string elements
List:Int()List:Int()Returns: list
Create an empty integer list.This list can hold only integer elements.
List:Date()List:Date()Returns: list
Create an empty date list.This list can hold only date/datetime elements.
List:Bool()List:Bool()Returns: list
Create an empty boolean list.This list can hold only boolean values.
List:Float()List:Float()Returns: list
Create an empty decimal list.This list can hold only decimal numbers.

 Map Functions

OperatorFormatReturns
get(<string>)<map>.get(<string>)Returns the String value to which the specified key is mapped in this identity hash map. Returns null if the map contains no mapping for this key.
size()<map>.size()Returns a number which represents the size of the given map.
isEmpty()<map>.isEmpty()Returns a Boolean value - True if this map contains no key-value mappings;
- False, if this map contains key-value mappings.
containKey(<string>)<map>.containKey(<string>)Returns a Boolean value - True, if this map contains a mapping for the specified key;
- False, if this map does not contain a mapping for the specified key.
containValue(<value>)<map>.containValue(<value>)Returns a Boolean value - True, if this map maps one or more keys to the specified value; otherwise false
keys()<map>.keys()Returns a List of the keys contained in this map.
toMap()<string>.toMap()Returns the Map from given JSON formated String
Map()Map()Returns the Empty Map

 XML Functions

OperatorFormatReturns
execute(<string>)<xml>.execute(<string>)Returns the Formated String from the given xpath and xml
toXML()<string>.toXml()Returns the Xml from given String

 URL Functions

OperatorFormatReturns
getUrl(<string>)getUrl(<url-string>)Returns map that contains the response
information
postUrl(<string>,<map>)postUrl(<url-string>,<data-map>)Returns map that contains the response
information
encodeUrl(<string>)encodeUrl(<url-string>)Encodes "all space characters" and the "other characters disallowed in a URL string" and returns the encoded string. For example,
myURL = "http://www.test/zohotest?name=John Doe&country=New Zealand&age=101";
myEncodedURL = encodeUrl(myURL);
This function can be used in getURL(), postURL() and openURL() Deluge tasks to encode the required URL and then pass the encoded URL string. For example,
userName=encodeUrl(input.Name);
openUrl("#View:SampleHTML?userName="+userName, "new window");

 Form Data Functions

OperatorFormatReturns
getFieldNames()getFieldNames()Returns list:string that contains all the fields in the form.
getFieldNames is supported only in the onSuccess action
getFieldValue()getFieldValue(<field-name>)Returns the value of the given field.

The sample application GetFieldNames  uses the getFieldNames() and getFieldValue() functions in Form A -> on add -> on success block . The script iterates each list value (field name) and gets the value of this field. The field name and value is updated in a user variable "fieldNameVsVal" and used in the message block of the sendmail() task.