Understanding function | Zoho Creator Help

Understand functions

In a nutshell

Functions in Zoho Creator are essential building blocks for implementing custom business logic using Deluge, Java, or Node.js. They act as modular units that can be invoked and reused across various components within an application or even shared between different applications. By encapsulating complex logic, functions promote better organization, enhance code readability, and simplify long-term maintenance.

Availability 

  1. Available in all plans of Creator
  2. Can be accessed by super admin, admins, and developers
Notes
Note: When a function is executed manually, its arguments can contain a maximum of 5,000 characters. This limit does not apply when the function is called from a workflow.

1. Overview

Functions in Zoho Creator promote the reusability of Deluge, Java, or Node.js scripts within an application or across multiple applications. They help modularize your logic, making code easier to maintain and understand. When you need to perform the same operation in different parts of your application, you can define that logic as a function and reuse it. Functions can also accept input parameters and return output values, enabling flexible and dynamic scripting.

Key functionalities of functions

  1. Write once and reuse utilities: Functions promote the reusability of scripts within an application or across multiple applications. They help you modularize your logic, making the code easier to manage and understand. When a specific scripting task needs to be repeated in different parts of an application, you can define it as a function and invoke it wherever required.
  2. Invoke functions with reports and pages: Functions can be integrated with various GUI elements in Zoho Creator, enhancing the way scripting interacts with your application. In reports, they can be added as custom actions, allowing users to run a function on selected records with a single click. Similarly, in panel and button components on pages, functions can be triggered directly based on user interaction, enabling seamless execution of custom logic within the interface.

Bridge the gap between applications: In addition to defining generic utilities as functions, you can also use Deluge functions to access and manipulate data across applications within your Zoho Creator account. This enables one application to operate on the data of another, similar to how member functions interact with objects in object-oriented programming. With this capability, applications can seamlessly communicate through functions, supporting more connected, efficient, and scalable solutions.

1.1. Deluge function

A Deluge function is used to implement logic using Zoho Creator’s native scripting language. It supports a wide range of capabilities, including handling various data types, performing collection operations, making API calls, and manipulating form objects. With Deluge functions, you can pass form objects as arguments to modify records and return computed results, making them ideal for data processing and application logic. These functions can also be invoked directly from the Creator UI through report actions as well as panels and buttons in pages, enabling seamless integration between user interactions and custom functionality.

Business use case:
An organization uses Zoho Creator to manage its operations through two separate applications: “Sales Orders” and “Inventory Management.” To ensure accurate stock tracking, a Deluge function is used to synchronize data between these applications. When a sales order is confirmed, the function is invoked to receive the product ID and ordered quantity, locate the corresponding inventory record in the other application, validate available stock, and deduct the required quantity from current stock levels. By automating this cross-application update through a reusable Deluge function, the organization ensures real-time inventory accuracy and prevents stock-out issues across its order processing workflow.

1.2. Java function

A Java function allows developers to write and execute custom Java code within Zoho Creator. It is especially useful when an application requires complex computations, integration with external Java libraries, or processing large datasets efficiently. They also support object-oriented programming, giving developers the flexibility to structure code using classes, methods, and reusable components.

Business use case:

An insurance company uses Zoho Creator to manage policy applications and premium calculations. Premium calculation involves risk scoring, actuarial formulas, and age-based multipliers. A Java function is created to process the applicant’s age, coverage amount, lifestyle factors, and claim history using advanced mathematical models. The function returns the final premium instantly, which is then displayed in the policy application form. This ensures accurate results, faster processing, and consistent application of complex rules.

1.3. Node.js function

A Node.js function enables you to write and execute server-side JavaScript within Zoho Creator, allowing them to build advanced logic using Node.js packages. Node.js functions are particularly useful when the application needs to handle asynchronous operations, integrate with third-party services, or process JSON-heavy data structures efficiently. They allow developers to leverage modern JavaScript features, perform non-blocking I/O operations, and incorporate external NPM libraries to extend an application's capabilities. Node.js functions

Use case: A manufacturing company uses IoT sensors to monitor machine temperature, vibration, and energy consumption. The IoT gateway sends bulk data to a cloud endpoint that exposes the data over a REST API. A Node.js function is used to fetch the data asynchronously, filter out noise, apply threshold checks, and generate alerts when abnormal readings are detected. The filtered data is pushed into Zoho Creator reports and dashboards for real-time monitoring. This enables predictive maintenance and reduces machine downtime.

2. Functions dashboard

The functions dashboard provides a consolidated view of all functions created across the application. It helps you to manage, categorize, search, and organize functions for easier maintenance.
2.1. Components of the functions dashboard
  1. New Function: Click New Function to create a custom function. This opens the function creation screen, where you can select the programming language, define input parameters, and write the required logic.
  2. Search: Use the search bar to quickly find a function by entering keywords related to the function name, namespace, language, or return type.
  3. Namespace pane: The left navigation pane lists all namespace in your application. Selecting a namespace displays only the functions stored within it. When All Functions is selected, every function in the application is shown and organized under its respective namespace, making it easier to locate and manage functions across different categories.
NotesNote: For Java and Node.js functions the namespace will always be Default and it cannot be modified.
  1. Function name: Displays the name of the function. Hover over the function name to reveal additional options such as, delete, copy or view references.
  2. References: Hover over the function name and click the references icon () to view and track all the locations where the function is referred across the applications in your Zoho Creator account.
  3. Delete: Hover over the function and click on the delete icon () that appears to delete the function permanently.
  4. Language: Shows the programming language used to create the function(Deluge, Java, or Node.js). It is fixed during the function creation and cannot be changed later.
  5. Return Type: Displays the data type of the function’s returned value. For Java and Node.js functions, the return type is always collection and cannot be modified.
  6. Syntax: Shows the syntax for invoking the function, helping users quickly reference how to call the function in workflows or other scripts.
  7. Copy Syntax: Hover over and click on the copy icon() to copy the function’s invocation syntax. This is useful when you need to know syntax to invoke the function call in a workflows.

3. Navigation guide


4. Points to note

  1. A function that calls itself (a recursive function) cannot be invoked more than 75 times. Exceeding this limit will result in a "Call Stack limit exceeded" error.
  2. Java and Node.js functions return a collection and belong to a default namespace. Neither the return type nor the namespace of these functions can be modified.

5. Related links

  1. Creating and managing functions
  2. Invoking a function
  3. Sample Deluge function
Whats next
Whats next

The next step after understanding about functions is to learn how to configure them effectively to implement your business logic.