Add Country codes to contact numbers.

Web forms is one of the easiest ways to generate leads in most organizations. Be it an access form that lets prospects watch an on-demand webinar, or a 'Contact us' form that a prospect fills out to reach you, this is one activity that you cannot do away with. However, not all prospects fill out the complete details, do they?

Zoho CRM's Phonebridge support lets you make direct calls from within the CRM. This week's custom function saves you the pain of having to edit the record manually to update the country code.

Add this function to any module including the custom ones. Change the module name and field names in the code and add the function to the module.

Getting started with the function:

Lets assume an example where you add the country code +91(India) to records in the Leads and Contacts module.

For Leads module:

  1. Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: "Add Country code-1".
  3. Select the moduleto be associated as Leads. Add a description(optional).
  4. Copy the code given below.
  5. Click "Edit arguments".
  6. Enter the name as "leadId" and select the value as "Lead Id".
  7. Click Save & Execute Script.
  8. Save the changes.

For Contacts module:

  1. Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: "Add Country code-2".
  3. Select the moduleto be associated as Contacts. Add a description(optional).
  4. Copy the code given below.
  5. Click "Edit arguments".
  6. Enter the name as "contactId" and select the value as "Contact Id".
  7. Click Save & Execute Script.
  8. Save the changes.

The code:

In Leads module:

leadIdStr = input.leadId.toString();
leadDetails = zoho.crm.getRecordById("Leads", input.leadId);
mobile = ifnull(leadDetails.get("Mobile"),"");
phone = ifnull(leadDetails.get("Phone"),"");
mp = map();
mp.put("Mobile", "+91" + mobile);
mp.put("Phone", "+91" + phone);
update = zoho.crm.updateRecord("Leads", leadIdStr, mp);
info update;
info mp;

In Contacts module:

contIdStr = input.contactId.toString();
acctDetails = zoho.crm.getRecordById(("Contacts"), input. contactId);
phone = ifnull(acctDetails.get("Phone"),"");
fax = ifnull(acctDetails.get("Fax"),"");
mp = map();
mp.put("Phone", "+91" + phone);
mp.put("Fax", "+91" + fax);
update = zoho.crm.updateRecord(("Contacts"), contIdStr, mp);
info update;
info mp;

Note:

  • The code is zoho.crm._getRecordById for Version 1.0 of APIs.
  • Change the country code from +91 to any preferred country code in the code.

 

Found this useful? Try it out and let us know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful!

Return to Tips