Add the international call prefix '+' to a phone number

Business scenario:

Any business involves a lot of communication. The most preferred way is to make a phone call. To make your life easier, Zoho CRM lets you call directly from the system. Naturally, you need an international call access code, which is the '+' symbol.

This custom function automatically adds the symbol to the phone number field. Additionally, this custom function also removes any alphabetical or special characters from the information in a numerical field. For instance, if you enter the phone number as "555-24r56" by mistake, it automatically changes to "+5552456".

Getting started with the function:

  1. Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: "International call prefix".
  3. Select the module to 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. Enter the name as "phone" and select the value as "Phone".
  8. Click Save & Execute Script.
  9. Save the changes.

The Code:


alphanumeric = (input.phone).getAlphaNumeric();
numeric = alphanumeric.removeAllAlpha();
info numeric ;
number = "+" + numeric ;
mp=map();
mp.put("Phone",number);
update=zoho.crm.update("Leads", leadId.toLong(), mp);
info mp;
info update;

 

Note:

  • The code is zoho.crm._getRecordById for Version 1.0 of APIs.
  • You can use the code for any modules. Change the name of the module from 'Leads' to whichever module you prefer and update the code accordingly.

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