How Can I...up

Functions are the user-defined type of routines that performs a specific set of operations whenever called. They are defined in Zoho Developer as stand-alone functions written in Deluge Scripts and are module independent. So, these functions can be called inside any of the workflows to achieve the specified functionality.

Return Type and Arguments

  • Single or multiple arguments of supported data types can be passed as parameters to the functions.
  • Functions can return values with one of the supported data types.
  • The supported data types are Integer,Float,String,Boolean,Date,Map and List.

Types of Functions

Functions in Zoho Developer are categorised as Normal functions and REST API functions.

Create Functions

Normal Functions

These are the functions invoked in other workflow custom functions, custom buttons, Related lists and schedules.

To create a function,

  1. Log in to the Zoho Developer Console and click Extensions for Zoho CRM.
  2. Select the extension you want to create a function for, and click Edit.
  3. Click Automate in the left pane, then click Functions.
  4. Click Create Function in Functions page.
  5. In the Create Function page, fill in the following details,
    • Name of the function
    • Invoke as REST API - "No" for normal functions and "Yes" for REST API functions.
    • Select the return type of the function
    • Click Add Arguments if any,and specify the arg name and type
  6. Click Save.

A sample code snippet in Deluge Script for a normal function is given below,

string pluginname.Copy_Address(stringmodule, int id)


m = { "module" : input.module, "id" : };

resp = zoho.crm.invokeConnector(("crm.get"), m);

response = (resp.get("response")).toMap();

data = response.get("data").toJSONList();

respstr = "";

for each rec in data


dataMap = rec.toMap();

idd = dataMap.get("id");

street = dataMap.get("Street");

city = dataMap.get("City");

state = dataMap.get("State");

country = dataMap.get("Country");

zip = dataMap.get("Zip_Code");

updateDataMap = map();

updateDataMap.put("installscript.Billing_Street", street);

updateDataMap.put("installscript.Billing_City", city);

updateDataMap.put("installscript.Billing_State", state);

updateDataMap.put("installscript.Billing_ZipCode", zip);

updateDataMap.put("installscript.Billing_Country", country);

updateDataMap.put("id", idd);

l = List();


updMap = { "module" : input.module, "data" : l };

updateResp = zoho.crm.invokeConnector("crm.update", updMap);

respstr = updateResp+"";


return respstr;


REST API Functions

Stand-alone functions can be invoked as a third-party API function also. These API functions from third-party applications are invoked as webhook URL with the "apikey" support. The API functions will return nothing. So their return type is void, but the parameter passed inside those functions will be of type Map and named as requestMap. The (Key, Value) pair of requestMap is given below,

ParametersThese are the map type entities found in requestMap as key-value pairs. For Example, in the third-party URL, http://somethirdpartyurl?zapikey=apikey&action=mailreceived,parameter is received as{"action":"mailreceived"} where "action" is the parameter name and "mailreceived" is the parameter value. Then the map is got through the following code,
params = requestMap.get("parameters");
tp_event_responseIf the third party service sends data in InputStream, then the map is got through the code,
response = input.requestMap.get("tp_event_response")

The following function code snippet calls the third-party "Twilio" REST API as a webhook and associates it with the application,

resp = input.requestMap;

twilioResp = (resp.get("parameters")).toMap();

fromNumber = twilioResp.get("From");

messageContent = twilioResp.get("Body");

LeadRespList = zoho.crm.searchRecords("Leads", "("(Mobile|=|" + fromNumber + ")");

for each LeadRespinLeadRespList


LeadId = LeadResp.get("LEADID");

if ((LeadId == null) || (LeadId == ""))


LeadId = "";



ContactRespList = zoho.crm.searchRecords("Contacts", "(Mobile|=|" + fromNumber + ")");

for each ContactRespinContactRespList


FinalId = ContactResp.get("CONTACTID");

if ((FinalId == null) || (FinalId == ""))


FinalId = "";



updateMap = { ("twilioext.Incoming_Message_Content") : messageContent, "twilioext.SMS_Texts_Name" : ("Incoming SMS"), "twilioext.Lead" : LeadId, "twilioext.Contact" : FinalId, "twilioext.Direction" : "Inbound" };

m = map();

l = List();


m.put("module", "twilio.SMS_Texts");

m.put("data", l);

resp = zoho.crm.invokeConnector("crm.create", m);

signalleadResp = zoho.crm.getRecordById("Leads", LeadId.toLong());

Leademail = signalleadResp.get("Email");

if ((Leademail != "") || (Leademail != null))


signalMap = map();

signalMap.put("signal_namespace", ("twilioext.incomingsmssignal"));

signalMap.put("email", Leademail);

signalMap.put("subject", ("Incoming SMS"));

signalMap.put("message", messageContent);

actionsList = List();

actionMap = map();

actionMap.put("type", "link");

actionMap.put("display_name", "View Email");

actionMap.put("url", "");


signalMap.put("actions", actionsList);

result = zoho.crm.invokeConnector("raisesignal", signalMap);

info result;


signalcontactResp = zoho.crm.getRecordById("Contacts", FinalId.toLong());

Contactemail = signalcontactResp.get("Email");

if ((Contactemail != "") || (Contactemail != null))


signalMapx = map();

signalMapx.put("signal_namespace", ("twilioext.incomingsmssignal"));

signalMapx.put("email", Contactemail);

signalMapx.put("subject", ("Incoming SMS"));

signalMapx.put("message", messageContent);

actionsListx = List();

actionMapx = map();

actionMapx.put("type", "link");

actionMapx.put("display_name", "View Email");

actionMapx.put("url", "");


signalMapx.put("actions", actionsListx);

resultx = zoho.crm.invokeConnector("raisesignal", signalMapx);

info resultx;


Invoke Functions

Stand-alone functions are invoked inside custom functions,custom buttons,related lists and schedules as given below,

resp = <EXTENSIONNAME>.Copy_Address("Leads", <LEADID>);

The "Copy_Address" function generates output API response as,

{\"name\":\"Saranya \",\"id\":\"2641973000000124009\"},
\"id\":\"2641973000000128184\",\"Created_By\":{\"name\":\"Saranya \",

A Rest API function can be invoked similar to a normal function wherever it is necessary.

Edit Functions

To edit a function

  1. Log in to your Zoho Developer Console and select Extensions for Zoho CRM.
  2. Select the extension your function is associated with, and click Edit.
  3. Click Automate option in the left pane, then click Functions.
  4. Select the required function from the list and click the Edit icon [].
  5. Edit and update the changes as per your requirements.

Delete Functions

To delete a function

  1. Log in to your Zoho Developer Console account and select Extensions for Zoho CRM.
  2. Select the extension associated with the function you wish to delete, and click Delete.
  3. Click Automate option in the left pane and click Functions.
  4. Choose the function that you want to delete, and click the Delete icon [].
  •  Calling a function inside another function is not supported.
  • Writing a function for Install Actions are also not supported.

Share this post : FacebookTwitter

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

Write to us: