Process Builder for Telephone Number Cleanup

We recently worked with a customer who wanted to show both the national (local) and international telephone numbers on their contact record.

We helped them set up a Process Builder action to accomplish this. 

The Process Builder

We created the Process Builder action and gave it name. We selected Contact as the object.

For the entry criteria, we specified "When RingsTrue status = Verified".

We did this to ensure that only telephone numbers that had already been checked by RingsTrue were copied over to the new fields.

Screen Shot 2017-09-05 at 10.54.18.png

The Actions

The Process Builder then has a number of Immediate Actions specified. 

These all have the same formula, the only difference between them was the name of the field that we were targeting for update.

Screen Shot 2017-09-05 at 10.54.30.png

The Formula

Finally, here is the formula we used to set the value of the new fields.

Using the LEN function, we counted the number of characters in the telephone number.

Then, using the Begins function we checked that the number started with a +1 (for a US number) or not.

Then, finally we did a nested Substitute command to replace any stray - or ) ( characters that might have been saved along with the number.

IF( LEN([Contact].Direct_Phone__c ) = 12 && Text([Contact].RingsTrue_Status__c ) == "All Numbers Verified" && BEGINS("+1",[Contact].Direct_Phone__c), RIGHT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE([Contact].Direct_Phone__c, "(", ""), ")", ""), " ", ""), "-", "") , 9), 

IF(!BEGINS("+1",[Contact].Direct_Phone__c) && Text([Contact].RingsTrue_Status__c ) == "All Numbers Verified" , RIGHT(SUBSTITUTE( SUBSTITUTE(SUBSTITUTE( SUBSTITUTE([Contact].Direct_Phone__c, "(", ""), ")", ""), " ", ""), "-", "") , 10),null))

Screen Shot 2017-09-05 at 10.55.00.png

We hope this write up helps if you'd like to add national and international phone formats to your own pages.

Let us know if you're interested in using RingsTrue to test and format your own phone numbers as well.