0

Our Custom_Object__Primary_Phone__c field (type: phone) has tens-of-thousands of numbers not formatted and I am looking for a way to touch this field to initiate an update so the result will be a correctly-formatted US phone number, e.g. (###) ###-####.

Is there a trick that anyone knows other than: export; strip excess characters and spaces; import?

1
  • You can create a batch script.
    – Mr.Frodo
    May 4, 2018 at 3:56

2 Answers 2

2

You could use apex or even writte trigger to make shure that any new record would be set up right :)

There is function REGEX with which you can check if that field is in corret format and if it is not some small code could change it.

To match you phone number use regex: "\([0-9]{3}\)[0-9]{3}-[0-9]{4}" if i am not misstaken at some moment ( still learning regex so please check it with some programer )

Edit: Usefull article: https://help.salesforce.com/articleView?id=000181563&language=en_US&type=1 And usefull page for regex: https://www.regular-expressions.info/nonprint.html

2
  • I was trying to avoid the excess work (that I do) to validate text I export/import. It look like using the data import wizard in the UI will reformat the phone numbers just by re-importing the list containing just ID and Phone.
    – Mike Stan.
    May 4, 2018 at 6:28
  • that is correct. Sory for over povered solution. But for future you have validation rule for phone number :) May 5, 2018 at 7:34
0

I was initially using the Data Loader to no avail and decided to use the Data Import Wizard with the same data file - this works!

Just map ID in the CSV file to Salesforce.Com:ID and the custom phone fields in the DB to the file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .