Call function

Overview

The call function Deluge task is used to invoke a custom function within another function.

Syntax

To invoke a function which returns a value,

<variable> = <function_name>(<parameters>)

To invoke a function which does not return any value,

<function_name>(<parameters>);

Parameters

ParamExplanation
<variable>
Variable to hold the returning value.
<function_name>
The name of the function that needs to be invoked must be complete, including any grouping such as a namespace or category, if applicable. 
For example, in Zoho Creator, if a function uses a namespace other than the default, it should be written as <namespace>.<function_name>. Similarly, in Zoho CRM, the function name should be represented as <category>.<function_name>.

If the function does not belong to any grouping, you can specify the function name directly. The type of grouping such as a category or namespace of a function depends on the service.
<parameters>

Usage of this parameter depends on the arguments specified or not while defining the function.

Note: An argument is a variable declared while defining a function. It is used to refer to a value provided as input while invoking the function. The input value is being referred to as parameter here.

The number of parameters and their data-types should be same as those of arguments while defining the function. If there's a mismatch, the script will not get saved.

Examples

Example 1: Reusing a common send mail function

In Zoho People, various onboarding workflows such as new hire creation, department assignment, or document submission may require sending email notifications. If each workflow contains its own email logic, it becomes difficult to maintain and update the code consistently.

To streamline this, you can create a parent function that handles all email-sending operations. Any onboarding workflow function (child function) can then call this function whenever an email needs to be triggered. This reduces redundancy and ensures consistent communication across all Zoho People processes.

#Parent Function
void send_mail(string to_address, string subject, string message) { sendmail [ from : zoho.adminuserid to : to_address subject : subject message : message ]; }
#Child Function
void notification() { send_mail("emily.kuy@zylker.com","Welcome Aboard","We welcome you aboard. Here's wishing you a great career with us."); }

Example 2: Centralizing Record Creation Logic in Zoho CRM

In Zoho CRM, multiple workflows, such as lead capture, event registration, or partner referrals, may require creating new Lead records. If each workflow has its own Lead-creation logic, maintaining consistency becomes difficult.

To simplify this, you can create a parent function that handles all Lead creation steps. Then, any workflow-specific function (child function) can call the parent function whenever a new Lead needs to be added. This ensures consistent data structure, reduces duplication, and makes updates easy.  

#Parent Function
map create_lead(string fname, string lname, string email, string source) { input_map = Map(); input_map.put("First_Name", fname); input_map.put("Last_Name", lname); input_map.put("Email", email); input_map.put("Lead_Source", source); response = zoho.crm.createRecord("Leads", input_map); return response; }
#Child Function
void event_signup() { lead_response = create_lead( "John", "Doe", "john.doe@zylker.com", "Event Registration" ); info lead_response; }

Points to note

Call function is not supported in Zoho Sheets, Zoho Connect, and Zoho Cliq.