ForceChallenges
ProblemsDailyNotesInterview
Sign in

Practice

All problemsSOQL practiceApex trigger challengesDaily challengeOpportunityTrigger.oldMapBefore UpdateBulkificationContactValidationGROUP BYSemi-JoinAccountBefore Insert

Interview questions

All questionsAdminAdministrationApexApex TriggerAsync ApexDevelopmentField ServiceField ServiceIntegrationLwc

By company

DeloitteSalesforceAccentureInfosysPwCCognizant

Learn

Study notes

ForceChallenges

AboutContact usPrivacy PolicyTerms of ServiceFor AI assistants (llms.txt)
© 2026 ForceChallenges · Salesforce SOQL & Apex trigger practice
Apex Trigger questions25 of 32
Apex TriggerMedium 1 min read

Why can't we perform DML operations on records in Trigger.new inside a before trigger?

Asked atCognizantInfosysEY

Answer

You don't need to, and you shouldn't. In a before trigger, changes you make directly to fields of Trigger.new records are automatically saved as part of the original DML. An explicit update Trigger.new is redundant and errors or causes recursion: for before insert records have no Id yet so the update fails, and for before update it re-fires triggers, risking the depth limit and wasting DML statements.

apex
for (Account a : Trigger.new) {
    a.Description = 'Updated'; // saved automatically
}
apex-triggertriggerdml
Practice SOQL & Apex
PreviousWhy are records in Trigger.new read-only in after triggers?Next Why is Trigger.newMap not available in before insert?

More Apex Trigger questions

  • How do you write a test class to achieve 100% code coverage and meaningful assertions for bulk triggers (testing with 200+ records)?
  • How do you handle UNABLE_TO_LOCK_ROW errors triggered during high-volume updates on parent records?
  • Does with sharing or without sharing on a Trigger Handler class affect SOQL and DML executed from the trigger?
  • Under what user context do Apex Triggers run (System Mode vs User Mode)?
  • How do Platform Events and Change Data Capture (CDC) triggers differ from standard SObject triggers?