Created
June 29, 2022 03:39
-
-
Save jeznag/677b6540b38149a9e1d0e5ef4b540164 to your computer and use it in GitHub Desktop.
Set country code for phone number using Deluge script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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