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
aj4aj4 

History tracking for Account Owner

Hi!
I want to track the account owner name by using following trigger .
 

if (Trigger.isUpdate) {

for (Account a : Trigger.new) {

 String ownerName  = a.Owner.Name;

}

}

ownerName returns null ,

 

How to get New and Old Owner Name value?

 

Thanks

 

benjasikbenjasik
You will have to query for the name based on the ownerid.  You should have the old and new ownerids.

You should be able to do this in one query (something like the below).

select firstname, lastname from user where id in (owneridnew, owneridold)
aj4aj4
Thanks.