Call function
Note: This task is applicable only to Zoho Creator.
Overview
The call function Deluge task is used to invoke a custom function defined in any Creator application in your account.
Return
Based on how the function is defined, it might or might not return a value.
The data-type of the returned value will be the data-type specified for the function while defining it.
Syntax
To invoke a function which returns a value, from current application
To invoke a function which does not return any value, from current application
To invoke a function which returns a value, from different application in same account
To invoke a function which does not return any value, from different application in same account
Param | Explanation |
---|---|
<variable> | Variable to hold the returning value. You can also specify a field name here, in the format input.<field_link_name>, to assign the returning value directly to the field. |
<function_name> | Name of the function to be invoked. |
<parameters> | Usage of this param depends on arguments specified or not while defining the function. 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 as parameter here. You can specify a variable or an expression which can be evaluated to a value as a parameter, or you can also specify a field name as a parameter, in the format input.<field_link_name>. 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. |
<application_link_name> | Link name of the application in which the function has been defined. |
This task can be used in the following events
When a record is Created | ||
On Load | Yes | |
On Validate | Yes | |
On Success | Yes | |
On User input | Yes | |
Subform on add row | Yes | |
Subform on delete row | Yes | |
When a record is Created or Edited | ||
On Load | Yes | |
On Validate | Yes | |
On Success | Yes | |
On User input | Yes | |
Subform on add row | Yes | |
Subform on delete row | Yes | |
When a record is Edited | ||
On Load | Yes | |
On Validate | Yes | |
On Success | Yes | |
On User input | Yes | |
Subform on add row | Yes | |
Subform on delete row | Yes | |
When a record is Deleted | ||
On Validate | Yes | |
On Success | Yes | |
Other workflow events | ||
On a scheduled date | Yes | |
During approval process | Yes | |
During payment process | Yes | |
In a Custom Function | Yes | |
In an Action item in report | Yes |
Example
Let us consider an Employee Management Creator application with the form 'Employee_Details', which has fields like Name, Department, Designation, and Salary. Within this application, we've created a 'getAvgSalary' function to compute the average salary of a department using the following script:
int getAvgSalary(String input_department) { avgSalary=Employee_Details[Department = input_department].avg(Salary); return avgSalary }
We can invoke the defined function for the "Sales" department in the same app using the following snippet:
Average_Sales_Salary = thisapp.getAvgSalary("Sales");
We can invoke the defined function for the "Sales" department in different Creator application using the following snippet:
Average_Sales_Salary = Empolyee_Management.getAvgSalary("Sales");