Trigger.new vs trigger.newmap - what's the difference?

444    Asked by dipesh_9001 in Salesforce , Asked on May 1, 2023

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 should I use trigger.new/trigger.newmap?

Answered by Ava Black

trigger.new is simply a list of the records being processed by the trigger, so if all you need to do is loop through them then you can use that.


trigger.newMap just allows you to target specific records by Id should you not need to process everything, or if you need to map other records back to these.



Your Answer

Interviews

Parent Categories