Skip to content

Instantly share code, notes, and snippets.

@jeznag
Created June 29, 2022 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeznag/677b6540b38149a9e1d0e5ef4b540164 to your computer and use it in GitHub Desktop.
Save jeznag/677b6540b38149a9e1d0e5ef4b540164 to your computer and use it in GitHub Desktop.
Set country code for phone number using Deluge script
lead_record = zoho.crm.getRecordById("Leads",lead_id);
mobile = lead_record.get("Mobile");
mobile_without_numeric_characters = mobile.replaceAll("[^\\d+]*","");
// example: (03) 1245 1(11)
// desired result: 031245111
country = lead_record.get("Country");
if(country == "Australia")
{
country_code = "+61";
}
else if(country == "United States")
{
country_code = "+1";
}
else if(country == "Germany")
{
country_code = "+49";
}
if(!mobile.startsWith("+"))
{
if(mobile_without_numeric_characters.startsWith("0"))
{
mobile_without_numeric_characters = mobile_without_numeric_characters.subString(1);
}
mobile_in_e164_format = country_code + mobile_without_numeric_characters;
}
else
{
mobile_in_e164_format = mobile_without_numeric_characters;
}
update_payload = {"Mobile":mobile_in_e164_format};
update_resp = zoho.crm.updateRecord("Leads",lead_id,update_payload);
info update_resp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment