Difference between trigger.new and trigger.newmap
I am really confused between these two.I know the theoretical differences between these like if you have the id then only you can use trigger.newmap and trigger.newmap returns an unordered list...
Leaving before insert we can use trigger.new and trigger.newmap both in after insert, after update and before update...
So please clear my doubt: in which scenarios i should use trigger.new/trigger.newmap?
And it is my request to you all to not copy-paste the standard definition...
Suppose you have a custom object
Trigger.Newmeans it is a
Trigger.NewMapmeans it is a
In before insert context your
Trigger.NewMapwill always be null because in before context records are not submitted to the database, so the Id is not generated yet. That's why in before insert we don't use
Trigger.NewMapBut in After insert, Id is generated so we can use
In case of before and after update, the Id has already been generated in the insert event. So we can use
Trigger.NewMapin before and after update.
Let me know if you have any confusion..