• Nick Nelson 9
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
I'm trying to write a 'before update' apex trigger that uses values from the oldmap of an object, but have been having issues. I have been using a text field on the object to test the LastModified values, but found that the new value, the oldmap value, and the newmap value are identical. 
The code below shows what I'm talking about:
trigger Example on Contact (before update) {
    for (Object o: trigger.new) {
        try {
            o.Description = 'Current LastModifiedBy: ' + o.LastModifiedById + ' \noldMap: ' + Trigger.OldMap.get(o.Id).LastModifiedById + ' \nnewMap: ' + trigger.newMap.get(o.Id).LastModifiedById;
        } catch (Exception e) {}
    }
}
Again: o.LastModifiedById, Trigger.OldMap.get(o.Id).LastModifiedById, and Trigger.NewMap.get(o.Id).LastModifiedById, all return the same value.

Any help would be appreciated, thanks.
 
I'm trying to write a 'before update' apex trigger that uses values from the oldmap of an object, but have been having issues. I have been using a text field on the object to test the LastModified values, but found that the new value, the oldmap value, and the newmap value are identical. 
The code below shows what I'm talking about:
trigger Example on Contact (before update) {
    for (Object o: trigger.new) {
        try {
            o.Description = 'Current LastModifiedBy: ' + o.LastModifiedById + ' \noldMap: ' + Trigger.OldMap.get(o.Id).LastModifiedById + ' \nnewMap: ' + trigger.newMap.get(o.Id).LastModifiedById;
        } catch (Exception e) {}
    }
}
Again: o.LastModifiedById, Trigger.OldMap.get(o.Id).LastModifiedById, and Trigger.NewMap.get(o.Id).LastModifiedById, all return the same value.

Any help would be appreciated, thanks.