0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Difference between trigger.new and trigger.newmap

Last updated at Posted at 2020-06-07

Apex トリガー覚え

Suppose you have a custom object Custom_obj__c

Trigger.New means it is a List

and

Trigger.NewMap means it is a map

順序があるか、無いか。
ループでidの一致を判定するか、idで直接読むか
https://salesforce.stackexchange.com/questions/104274/difference-between-trigger-new-and-trigger-newmap

What to use depends on what you're doing - if you have an ID of an object you need to do something with, using the map makes more sense as you can use newMap.get(). Otherwise you'd have to loop over all the elements in Trigger.new and look for a matching ID. Similarly, if you have multiple loops over each item the trigger is operating on, the list returned by Trigger.new may be the better bet.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?