User Story
As a user, I want the Billing Country field of an Account to be automatically updated to "USA" when the Account is created with a Billing Country value of "America" or "AMERICA". This ensures that the correct country value is stored in the system and can be utilized for reporting purposes.
Codes
trigger AccountTrigger on Account (before insert, before update) {
for(Account ac : Trigger.new){
if(ac.BillingCountry == 'America' || ac.BillingCountry == 'AMERICA'){
ac.BillingCountry = 'USA';
}
}
}
OR
trigger AccountTrigger on Account (before insert, before update) {
for (Account ac : Trigger.new) {
if (ac.BillingCountry != null && ac.BillingCountry.toLowerCase() == 'america') {
ac.BillingCountry = 'USA';
}
}
}
Video
Video does not exists.