What does the trigger.new variable contain in Apex triggers?

Study for the Salesforce Platform Developer Exam. Study with flashcards and multiple choice questions, each question has hints and explanations. Get ready for your exam!

The trigger.new variable in Apex triggers contains a list of new versions of sObject records that are currently being processed by the trigger. When a record is created or updated, trigger.new holds the updated representation of these records, enabling developers to access the new field values before they are committed to the database.

This variable is particularly useful in "before" triggers, where developers can modify field values before they are saved. In "after" triggers, trigger.new allows access to the records as they appear after being saved to the database, which is essential for performing actions that rely on the new state of the data.

The other options do not accurately reflect the purpose of trigger.new; for example, the notion of it being a map or containing both old and new records doesn't align with its intended function. Instead, trigger.old is the variable that actually contains the original versions of the sObject records prior to the update, which distinguishes between current and previous states.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy