CRT-450 practice question 18 of 30
Which statement should be used to allow some of the records in a list of records to be inserted if others fail to be inserted?
Full set: 201 questionsThe Database.insert() method provides an optional boolean parameter, allOrNone. When this parameter is set to false, the DML operation allows for partial success. This means if one record in the list fails to be inserted due to validation rules or other errors, the remaining valid records in the list will still be committed to the database. The method returns an array of Database.SaveResult objects, which can be inspected to identify which records succeeded and which failed, along with the reasons for failure.
1. Salesforce Apex Developer Guide: In the "Database Class Methods" section
it states
"The Database methods are static and are called on the class name. ... The optional allOrNone parameter specifies whether the operation can partially succeed. If you specify false for this parameter and a record fails
the remainder of the DML operation can still succeed."
Reference: Salesforce Developers
Apex Developer Guide
"DML Statements vs. Database Class Methods".
2. Salesforce Apex Developer Guide: The guide further clarifies the behavior of the allOrNone parameter for Database.insert: "The optional allOrNone parameter is available only for Database methods
not DML statements. This parameter specifies whether to allow partial success of the DML operation. If it’s set to false
and if a record in the list fails
the successful records are still committed...".
Reference: Salesforce Developers
Apex Developer Guide
"Performing DML Operations".
Keep practicing
Take the free CRT-450 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other CRT-450 practice questions
- Question 2A developer created a child Lightning web component nested inside a parent Lightning web …
- Question 4A developer needs to make a custom Lightning Web Component available in the Salesforce Cl…
- Question 6Given the following Apex statement: Account myAccount = [SELECT Id, Name FROM Account); W…
- Question 8Which action causes a before trigger to fire by default for Accounts?
- Question 9Universal Containers (UC) wants to lower its shipping cost while making the shipping proc…
- Question 10A custom picklist field, Pool Preference ¢, exists on a custom object. The picklist conta…
