You need to sign in to do that
Don't have an account?

Apex trigger after update
Hi All,
I have written a trigger on Account.
I am storing mutiple phone number values in phone number field and I am splitting those values into three different fields.
It is working fine. If I update any phone number in phone field, I want to see the same change in those fields. This updation is not working.
Please suggest me the changes
This is the code I have written.
trigger AccountPhoneTrigger on Account (before insert) {
List<String> descriptionValues;
List<Id> accountIds = new List<Id>();
for(Account acc: Trigger.New){
if(!String.isBlank(acc.Phone)){
descriptionValues = acc.Phone.split(',');
for(Integer count = 0; count < descriptionValues.size(); count ++){
acc.Pho1__c = descriptionValues[0].trim();
acc.Pho2__c = descriptionValues[1].trim();
acc.Pho3__c = descriptionValues[2].trim();
}
}
}
}
I have written a trigger on Account.
I am storing mutiple phone number values in phone number field and I am splitting those values into three different fields.
It is working fine. If I update any phone number in phone field, I want to see the same change in those fields. This updation is not working.
Please suggest me the changes
This is the code I have written.
trigger AccountPhoneTrigger on Account (before insert) {
List<String> descriptionValues;
List<Id> accountIds = new List<Id>();
for(Account acc: Trigger.New){
if(!String.isBlank(acc.Phone)){
descriptionValues = acc.Phone.split(',');
for(Integer count = 0; count < descriptionValues.size(); count ++){
acc.Pho1__c = descriptionValues[0].trim();
acc.Pho2__c = descriptionValues[1].trim();
acc.Pho3__c = descriptionValues[2].trim();
}
}
}
}
Your code looks perfect but you havn't add after update event in your trigger.
Thats y its not working.
Try this code
Let me know if you have any issues.
Mark it as best answer if it works.
Thanks.
All Answers
mark it best answer if it helps you
Your code looks perfect but you havn't add after update event in your trigger.
Thats y its not working.
Try this code
Let me know if you have any issues.
Mark it as best answer if it works.
Thanks.