• Igor Petrovych 4
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies
Hi All,

I want to write a validation rule on phone number custom field. I want to check if the phone number cotains the user's iso country code. For example the user creating or updatin the record has its iso country as INDIA. The validation rule must check if the phone number contains +91. I want to write that for many countries.

Thanks,
Anuj
In our org we currently use the Javascript version of libphonenumber (https://github.com/googlei18n/libphonenumber) to validate and correct phone numbers in the Salesforce UI, storing the library as a static resource and calling it from an override page layout, a simple Visualforce page used for the lead object. Validation works very reliably but takes 2-3 seconds, and the override page can cause some unwanted side-effects. Validation allows users to call leads using the Google-built Click-to-Dial softphone built into our Salesforce instance, something out Support team is trialling for a wider launch.

If we wanted to validate phone numbers in the background, so that they were properly formatted before a user ever saw them in the UI, would one alternative be to use the Java or Python version of the library to write a phone-validation service on Heroku and use Heroku Connect (https://devcenter.heroku.com/articles/herokuconnect) to sync the data with Salesforce?

The libphonenumber code library does a good job normalising and formatting phone numbers to national or international standards - not just for the North American zone but worldwide. Has anyone incorporated the JS version into an Apex class? If so, would you be wiling to post a code sample? This topics seems a bit of a gap in developerforce.

Has anyone seen a formula that based off the country field being a foreign country than the phone field would format to the correct sectioning of the phone number
 
i.e.
 
IF
 
Country Field = China
 
THAN update phone field upon save to
 
Phone Field=  +86 (10) 6505 0998
 
 
Any help would be appreciated.
 
Thank you