Question: 1 / 335

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

A list of new records divided by their type

A map containing old and new records

A list of new versions of sObject records

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.

A list of all records that triggered the process

Next

Report this question