function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
smerrillsmerrill 

Formula field to automatically add International number format

I'm trying to build a formula to accomplish the following:

  • Reformat a phone number field to display the full US calling format instead of the local calling format.
  • Example: In the UK numbers have one of three prefixes, 01, 02, or 03. When my leads post from web to lead, they are formatted as if I were located in the UK and calling these leads. I am located in the US where I am required to dial 011 44 and then the number.  


Here is my code:

 

 

if(contains (Phone, "01"), substitute(Phone,"01", "011 44 1"),
if (contains (Phone, "02"), substitute(Phone, "02", "011 44 2"),
if (contains (Phone, "03"), substitute(Phone, "03", "011 44 3"),
""
)))

 


 

 

The formula works well, except for cases where there exists a "01", "02", or "03" somewhere other that the begining of the number, which it will then replace with the designated text. 

 

How do I get my formula to only replace the value of the phone number in cases which it begins with an "01", "02", or "03" without searching the entire field. 

 

Thanks in advance. 


Steve

Message Edited by smerrill on 05-20-2009 03:31 PM
Best Answer chosen by Admin (Salesforce Developers) 
Kent ManningKent Manning

Try changing your statement from "Contains" to "Begins" and see if that works.

 

 

if(begins (Phone, "01"), substitute(Phone,"01", "011 44 1"),
if (begins (Phone, "02"), substitute(Phone, "02", "011 44 2"),
if (begins (Phone, "03"), substitute(Phone, "03", "011 44 3"),
""
)))

All Answers

Kent ManningKent Manning

Try changing your statement from "Contains" to "Begins" and see if that works.

 

 

if(begins (Phone, "01"), substitute(Phone,"01", "011 44 1"),
if (begins (Phone, "02"), substitute(Phone, "02", "011 44 2"),
if (begins (Phone, "03"), substitute(Phone, "03", "011 44 3"),
""
)))
This was selected as the best answer
smerrillsmerrill
That worked. Thanks!