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
Development questions14 of 102
DevelopmentHard 1 min read

Write a SOQL query to retrieve Accounts ordered by Name in ascending order, locked for editing in Apex (FOR UPDATE), while enforcing User Mode permissions (WITH USER_MODE).

Asked atSalesforceDeloitteSlalom

Answer

Place WITH USER_MODE after the WHERE clause and before ORDER BY, then add FOR UPDATE at the end.

apex
List<Account> accs = [SELECT Id, Name FROM Account WITH USER_MODE ORDER BY Name ASC FOR UPDATE];

This enforces the running user's object, field and sharing permissions while locking the returned rows for the rest of the transaction. Keep the transaction short to avoid UNABLE_TO_LOCK_ROW errors for others.

soqlscenariolockinguser-mode
Practice SOQL & Apex
PreviousWhat is Lightning Message Service (LMS) and how do you use it to communicate between components?Next Write a SOQL query to fetch ProcessInstance and ProcessInstanceWorkitem records to find all pending Approval requests assigned to the current user (UserInfo.getUserId()).

More Development questions

  • What is reactivity in LWC and when does a field trigger a re-render?
  • What are the best practices to improve LWC performance?
  • How do you unit test an LWC with Jest?
  • How do you use a third-party JavaScript library or static resource in LWC?
  • Why can renderedCallback run multiple times and how do you prevent repeated execution?