function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Varun AnnadataVarun Annadata 

What records does trigger.new get?

What does Trigger.new list get when a trigger is fired?Does it get the records which caused the trigger to fire?
Best Answer chosen by Varun Annadata
Glyn Anderson 3Glyn Anderson 3
Varun,  Yes - Trigger.new contains the records that caused the trigger to fire.  For example:

<pre>
// Trigger.new will contain one record
insert new Case();

// Trigger.new will contain three records
insert new List<Case>{ new Case(), new Case(), new Case() };
</pre>

All Answers

PawanKumarPawanKumar
Trigger.new : Returns a list of the new versions of the sObject records. Note that this sObject list is only available in insert and update triggers, and the records can only be modified in before triggers.
 
Trigger.old : Returns a list of the old versions of the sObject records. Note that this sObject list is only available in update and delete triggers.
 
For more info go through this link:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm

Trailhead Unit
https://trailhead.salesforce.com/en/modules/apex_triggers/units/apex_triggers_intro

Regards,
Pawan Kumar
Glyn Anderson 3Glyn Anderson 3
Varun,  Yes - Trigger.new contains the records that caused the trigger to fire.  For example:

<pre>
// Trigger.new will contain one record
insert new Case();

// Trigger.new will contain three records
insert new List<Case>{ new Case(), new Case(), new Case() };
</pre>
This was selected as the best answer
Varun AnnadataVarun Annadata
Glyn thank you.