User Story
Create a trigger which updates the format of the phone number
Expected Outcome
(456) 212 - 4554
Code
Apex Trigger
Apex Handler Class
public class AccountTriggerHandler {
public static void PhoneNumberFormatting(List<Account> acList){
String formattedPhoneNumber ='';
for(Account ac : acList){
if(ac.Phone != Null && ac.Phone.length() ==10){
formattedPhoneNumber = '(' + ac.Phone.subString(0,3) + ') ' + ac.Phone.subString(3,6) + ' * '+ ac.Phone.subString(6,10);
}
ac.Phone = formattedPhoneNumber;
}
}
}
Video
Video does not exists.