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
Anthony WheelerAnthony Wheeler 

Trigger.old and Trigger.new returning same value

I'm trying to write a trigger that tests if a custom field on a User record changes after the record is updated. In my test class, before the update, the field is assigned to null. It is then populated and updated, but in the trigger, Trigger.old and Trigger.new are returning the updated field. I have verified this through the debug log. Not sure why this is happening. 
pconpcon
Can you please provide your test class?

NOTE: When adding code please use the "Add a code sample" button (icon <>) to increase readability and make it easier to reference.
Anthony WheelerAnthony Wheeler
Figured it out. I wasn't getting it directly from trigger.old. I was just doing a query, while testing that the id was in trigger.old. Changed it to get the field directly from Trigger.old and it started working.