Custom Functions

Custom Functions

Custom functions are user built functions that helps them to add new features to Zoho CRM as per their requirement. These are written in deluge script and are easy to construct. The syntax and logic are simple to formulate, and aid in continuous development of the code.

Custom functions liberates the user from a hard coded CRM to a flexible one. They feel an actual control over the CRM which helps them find endless possibilities to make their work easier and faster. Some of the benefits of having custom functions are

  • Achieve workflow automation by writing custom functions to control the flow. For example, automated lead assignment.
  • Perform operations like Get, Put, Update or Delete data for any event happening in CRM. For example, sending automated email to a customer whenever they are added in the system.
  • Make extensions on the Zoho Developer Console and subsequently publishing them in the marketplace. Similarly, make connectors associated with the extensions to integrate the CRM with any third-party application.

Custom function find its application in the following areas:

  • Custom Buttons - Define your own button action by writing a custom function using Deluge script. Whenever the button is clicked, the associated custom function will be triggered.
  • Custom Related Lists - Using a custom function, you can display related information associated to a particular record, in the record's details page.
  • Connector and Connected Apps - You can write a custom function to enable the integration of Zoho CRM with a third party service using connectors and connected apps.


Automated Lead assignment

This function automatically assigns the leads to different users.
Saves a lot of time fot the admin and only does it to the active users, so that if any one of them is on vacation it skips that user and give it to the next in queue.

lead_id = input.lead.get("LEADID");
m = map();
m.put("module", "Leads");
datamap = {"id", lead_id.toLong()};
m.put("data", datamap);
resp = zoho.crm.invokeConnector("crm.get", m);
lead_number = (resp.get("Lead_Number")).toLong();
assignRule = resp.get("Assign_Using_Active_Assignment_Rule");
UserDetail = getUrl((""), { "Authorization" : "Zoho-authtoken 332bcbadce0a72d4cf76a190d31194a8" });
UserDetailtoMap = UserDetail.toMap();
UserDetailtoMap2 = (UserDetailtoMap.get("users")).toMap();
UserDetailtoList = UserDetailtoMap2.get("user").toJSONList();
j = 0;
valuez = map();
for each index i in UserDetailtoList
fetchingDetail= (UserDetailtoList.get(i)).toMap();
if (fetchingDetail.containKey("id"))
valuez.put(j.toString(), fetchingDetail.get("id"));
j = j.toLong();
j = (j + 1);
max_lead_level1 = (i + 1);
max_lead_level = (max_lead_level1).toLong();
ans = (abs(((l_number - 1) % max_lead_level)) + 1);
updateMap = map();
updateMap.put("id", lead_id.toString());
updateMap.put("Round_Robin_Id_Auto_Filled", ans);
updateMap.put("Max_Lead_Level_Auto_Filled", max_lead_level);
m1 = map();
m1.put("module", "Leads");
m1.put("data", updateMap);
updatedResponse = zoho.crm.invokeConnector("crm.update", m1);
info updatedResponse;
if (assignRule == "true")
ans = (ans - 1);
answ = ans.toString();
ownerid = valuez.get(answ);
mapp = map(); mapp.put("id", lead_id.toString());
mapp.put("SMOWNERID", ownerid);
newUpdateMap = map();
newUpdateMap.put("module", "Leads");
newUpdateMap.put("data", mapp);
updatedResponse2 = zoho.crm.invokeConnector("crm.update", newUpdateMap);
info updatedResponse2;

  1. Fetch the lead id from the lead module
  2. Get all the related records for the same.
  3. Get Lead number
  4. Assign using active assignmemnt method
  5. Get all the user information in the list after running the API from the plugin round robin assignment.
  6. Then mapping a user to a lead as and when a new lead is generated.

Function to invoke connector task

eventid = input.event.get("EVENTID"); gtm_id = input.event.get("meeting.GoToMeetingId");
mapp = { "meetingId" : gtm_id };
respMap = zoho.crm.invokeConnector("meeting.connector_go_to_meeting.deletemeeting", mapp);
info respMap;

  1. Event ID is being procured
  2. Goto meeting is being fetched from that particular event
  3. Mapping of dynamic values in connector
  4. Invoking connector and displaying response

Function to put the grand total amount from quote module and place it in the respective Potential module.

quoteId = input.quote.get("QUOTEID");   
resp = zoho.crm.getRelatedRecords("Potentials", "Quotes", quoteId);   
value = zoho.crm.getRecordById("Quotes", quoteId.toLong());   
amount = value.get("Grand Total");    
potential_amount = map();
potentialId = value.get("POTENTIALID");
potential_amount.put("id", potentialId);
potential_amount.put("Amount", amount.toLong());
potentialMap = map();
potentialMap.put("module", "Potentials");
potentialMap.put("data", potential_amount);
updateResp = zoho.crm.invokeConnector("crm.update", potentialMap);

  1. Get Quoteid of the respectrive quote module
  2. Get the information of the Potential related to that Quote.
  3. Get all the related records corresponding to that Quote.
  4. Extract the Potentail ID.
  5. Finally put the Potential name , Its ID and the amount quoted and putting it in Potential module.

Share this post :


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

Write to us: