Welcome back everyone!
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 custom function:
- Go to Setup > Automations > Actions > Custom Functions > Configure Custom Function > Write your own.
- Provide a name for the custom function. For example: “Add prefix”. Add a description(optional).
- Select the module as Leads. Add a description(optional).
- Click “Free flow scripting”.
- Copy the code given below.
- Click “Edit arguments”.
- Enter the name as “leadId” and select the value as “Lead Id”.
- Enter the name as "phone" and select the value as "Phone"
- Save the changes.
The script:
Code for Version 2.0 API:
alphanumeric = (input.phone).toString().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;
Code for Version 1.0 API:
leadIdStr = input.leadId.toString();
alphanumeric = (input.phone).getAlphaNumeric();
numeric = alphanumeric.removeAllAlpha();
info numeric ;
number = "+" + numeric ;
mp=map();
mp.put("Phone",number);
update=zoho.crm.updateRecord("Leads", leadIdStr, mp);
info mp;
info update;
Note:
- 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 me know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful. Do check out other custom functions shared in this series here.
See you all next week with another interesting custom function. Ciao!