I have created a before updated trigger and I am trying to update the title of the user. After saving the record, the title does not get populated although when I debug the value it actually hold it. Below is the code : newUserList is Trigger.new and the below logic is called from before update trigger.
public static void updateUserTitlePrefix(List<User> newUserList){
for(User userRecord : [SELECT Id, Name, TitleFROM User WHERE Id IN:newUserList]) {
if(userRecord.Title != null) {
userRecord.Title = 'ABC ' + userRecord.Title;
System.debug('userRecord.Title1 ::'+ userRecord.Title);
} else {
userRecord.Title = 'ABC ';
System.debug('userRecord.Title2 ::'+ userRecord.Title);
}
}
}
When I checked the logs userRecord.Title actually holds the correct value. Not sure what am I missing.