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
Serena SchultzSerena Schultz 

Workflow formula to replace first digit in phone number with "+256"

Hello! 

I'm trying to create a workflow rule/field update formula to to replace first digit in phone number field with "+256". (Example: 0702475002 should be +256702475002).

I've tried the following two forumulas so far without luck - any help would be appreciated!! 

if(begins (Phone_Number__c, "0"), 
substitute(Phone_Number__c,"0", “+256"),"")


IF(BEGINS(Phone_Number__c,"0"), RIGHT(Phone_Number__c,1), “+256”)

Serena
Best Answer chosen by Serena Schultz
Alain CabonAlain Cabon
Hello Serena,

New rule: remove the first digit (no matter the number) and then add the "+256" and the rest of the number.

if(len(Phone_Number__c) > 1, 
"+256"+right(Phone_Number__c, LEN(Phone_Number__c)-1 ),Phone_Number__c)

Best regards
Alain

All Answers

Serena SchultzSerena Schultz
I'm almost there with this formula (below), which returns +2560702475002. I just need that first zero (in the 4th spot) to be removed.

SUBSTITUTE(LEFT(Phone_Number__c,1), "0", "+256"+Phone_Number__c)
Serena SchultzSerena Schultz
Okay, I think I've got a solution with the formula below. However, I believe that this formula will only work with then phone number begins with a 0. I'd perfer it if it would remove the first digit (no matter the number) and then add the "+256" and the rest of the number.

SUBSTITUTE(LEFT(Phone_Number__c,1), "0", "+256"+MID(Phone_Number__c, 2, 10))
Alain CabonAlain Cabon
Hello Serena,

if(and(begins (Phone_Number__c, "0"), len(Phone_Number__c) > 1), 
"+256"+right(Phone_Number__c, LEN(Phone_Number__c)-1 ),Phone_Number__c)

Best regards
Alain
Alain CabonAlain Cabon
Hello Serena,

New rule: remove the first digit (no matter the number) and then add the "+256" and the rest of the number.

if(len(Phone_Number__c) > 1, 
"+256"+right(Phone_Number__c, LEN(Phone_Number__c)-1 ),Phone_Number__c)

Best regards
Alain
This was selected as the best answer
Serena SchultzSerena Schultz
Amazing. THANK YOU!