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
Vikas U MishraVikas U Mishra 

Old Country Code

We are getting issue with Standard Account field "BillingCountry" while writting Trigger.
We are getting not getting new value for BeforeUpdate Trigger.

Not sure what may be issue, we have created custom field for Country and same is working properly.

Pls, check following debug log showing old and new values same.
|USER_DEBUG|[106]|DEBUG|Old Country: United States
|STATEMENT_EXECUTE|[107]
|HEAP_ALLOCATE|[107]|Bytes:14
|HEAP_ALLOCATE|[107]|Bytes:27
|USER_DEBUG|[107]|DEBUG|New Country : United States
|STATEMENT_EXECUTE|[108]
|HEAP_ALLOCATE|[108]|Bytes:18
|HEAP_ALLOCATE|[108]|Bytes:20
|USER_DEBUG|[108]|DEBUG|Old Country Code: US
|STATEMENT_EXECUTE|[109]
|HEAP_ALLOCATE|[109]|Bytes:18
|HEAP_ALLOCATE|[109]|Bytes:20
|USER_DEBUG|[109]|DEBUG|New Country Code: US

 
RD@SFRD@SF
Hi Vikas,
Can you share the trigger code.
Debug log seems to be fine

Regards
RD
Vikas U MishraVikas U Mishra
Pls, find code..

trigger AccountAddressTrigger on Account (before insert, before update) {
    
    // Process only for before insert or update
    if((Trigger.isInsert || Trigger.isUpdate) && Trigger.isBefore) {        
        List<Account> newValueList = Trigger.New;
        Map<Id, SObject> mapOldItems = Trigger.OldMap;
        
        for(Account acc:newValueList){
        
            Account oldAccountObj = null;
            if(acc.Id!=null && mapOldItems!=null) {
                oldAccountObj = (Account)mapOldItems.get(acc.Id);
                system.debug('Old Country: ' + oldAccountObj.BillingCountry);
                system.debug('New Country : ' + acc.BillingCountry);
                system.debug('Old Country Code : ' + oldAccountObj.BillingCountryCode);
                system.debug('New Country Code : ' + acc.BillingCountryCode);
            }
            
            // Check if checkbox is true
            if(acc.Match_Billing_Address__c) {
                acc.ShippingPostalCode = acc.BillingPostalCode;
            }
        }        
    }
}

Good part is now I see I am getting updated Country Code...for changing country name.

|USER_DEBUG|[13]|DEBUG|Old Country: United States
|STATEMENT_EXECUTE|[14]
|HEAP_ALLOCATE|[14]|Bytes:14
|HEAP_ALLOCATE|[14]|Bytes:27
|USER_DEBUG|[14]|DEBUG|New Country : United States
|STATEMENT_EXECUTE|[15]
|HEAP_ALLOCATE|[15]|Bytes:19
|HEAP_ALLOCATE|[15]|Bytes:21
|USER_DEBUG|[15]|DEBUG|Old Country Code : US
|STATEMENT_EXECUTE|[16]
|HEAP_ALLOCATE|[16]|Bytes:19
|HEAP_ALLOCATE|[16]|Bytes:21
|USER_DEBUG|[16]|DEBUG|New Country Code : IN