The telephone number fields like mobile phone and home phone on the Person Account object contain descriptive words in like:

07970 123 123 (dad mobile)


How could I get a list/report of all records with the invalid characters in these fields?

  • I was going to suggest creating a custom formula field with the REGEX function, but unfortunately REGEX is not available in formula fields, only for validation rules and workflow rules. Oct 13 '18 at 17:34

I don't know of functions that can do this in SOQL. The quick solution may be to write a simple Apex, extract phone numbers, compare using ASCII values, and output defaulters.

Something like -

Pattern numPattern = Pattern.compile('[0-9]{10}');  // not for your use case! I am weak in REGEX :)
Matcher phMatcher = numPattern.matcher(sPhone);  


System.debug('Invalid list: ' + invalidList);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.