Creator Help

Defining A Function

  Steps in defining functions

1. Select Workflow to invoke the Script builder.

2. Click on Functions tab displayed in the Script Editor. If no functions are defined, the dialog to create a new function will be displayed.  If you have one or more functions already defined, the list of function names will be displayed on the left-side. Click on the New Function button displayed on the top left corner, to define a new function. 

3. Specify the function name, namespace, return type and arguments, if any, to be passed to this function.

  • Function name: Name is the identifier by which it will be possible to call the function. Any meaningful name without white spaces can be specified as function name. The name must not contain any white spaces.
  • Namespace: Related functions can be grouped under a name based on their purpose, for easy maintanance. Any meaningful name without white spaces can be specified as namespace.
  • Return Type: Return type is the data type specifier of the data returned by the function. If no data is returned by the function, the return type must be specified as void.
  • Arguments (as many as needed): They allow to pass parameters to the function when it is called. Each argument consists of a data type specifier followed by an identifier, like any regular variable declaration (for example: int a) The different parameters are separated by commas.

For example, let us create a simple function to calculate the number of days. Specify the function name as CalculateDays. This function takes arguments sdate and edate of type date, as inputs to this function, and the return type is intCreate the function by selecting the Create the Function button.

4. The function CalculateDays will be added to the Functions tree under the namespace Calculations, as shown in the screen-shot below. Select the function from the Functions tree and add the required deluge statements to be executed, using drag-n-drop or Free-flow scripting. Select Save Script to save the function.

5. You can use the Execute Script option to test if your function is executed as defined, by specifying the required values as arguments to the function. For example, to execute the Calculate days function, we specify a value for the arguments (sdate,edate). By clicking the On submit, the deluge statement is executed. The dialog box below shown below requests the user to enter a value for input arguments.


Select the Write Script option to define a function by directly writing or pasting the script code in the Functions dialog, as shown in the screen-shot below:

Adding form object as argument to the function

Zoho Creator supports Form Objects that can be passed as argument to a user-defined Function. A Form Object represents a collection of records in a Form. Refer the topic Passing Form object as argument to the function, for more information.

What is name space?

In the screen-shot given below, Calculations is the namespace that groups similar functions related to calculations. Here, CalculateDays, CalculateHours etc are function names. If the function is called within the application where it is defined, the namespace will be appended with the word thisapp. If the function is called from a different application, the namespace will be appended with the actual application name, where it is defined.

For example, if the function CalculateDays is called from the Sample application, the function call will be in the following format: Calculations.CalculateDays(),


- Calculations is the namespace,

- CalculateDays is the function name.

  Related Links

Calling a Function

Configuring a Function as Custom Action

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: