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
Naveen Nelavelli 9Naveen Nelavelli 9 

Trigger.new on Account Object returning old values for BillingCountry field (before update event)

I am surprised to see this behaviour .I am updating billingCountry and billingpostalcode of Account.In trigger.new i am recieving billingpostalcode new value but not same case with billingcountry.
codesnippet:
trigger AccountTrigger on Account (before insert ,before update,after insert,after update) {
   if(trigger.isBefore){
       for(account accnt:trigger.new){
            system.debug('testing'+accnt.BillingCountry+accnt.BillingPostalCode);           
        } 
   } 
}

am i only the one who is facing this?
Best Answer chosen by Naveen Nelavelli 9
Naveen Nelavelli 9Naveen Nelavelli 9
Billingcountry will give you old value ,billingcountrycode will be giving new value  in trigger.new. when you update billingcountry it basically updates billingcountrycode first ,then it updates billingcountry. 

All Answers

B TulasiB Tulasi
Hi Naveen,

Trigger.new : Returns a list of the new versions of the sObject records. Note that this sObject list is only available in insert and update triggers, and the records can only be modified in before triggers.
 
 Trigger.old : Returns a list of the old versions of the sObject records. Note that this sObject list is only available in update and delete triggers.

Here, you are getting new values, not old values. old value means existing data from database.
Naveen Nelavelli 9Naveen Nelavelli 9
Billingcountry will give you old value ,billingcountrycode will be giving new value  in trigger.new. when you update billingcountry it basically updates billingcountrycode first ,then it updates billingcountry. 
This was selected as the best answer