function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
NandiniNandini 

Database.update for List and Map ?

Hi Team,

I have a doubt on Database.update .
Database.update(oppToUpdate,false); In this statement what is the use of ' false' , is it mandatory ? ( passing list obj).
Database.update(mapToUpdate.values()); In this statement we need to put ' false' or not necessary. (passing map).

Please let me know.

Thanks,
Nandu.
Raj VakatiRaj Vakati
Database.update(oppToUpdate,false)  false indicates all or none based commit data to database

Database.update(mapToUpdate.values()) --> Your are not passing any values to the second param to its defualt false .. and your are passing the values from the map i.e list

 
Raj VakatiRaj Vakati

Modifies one or more existing sObject records, such as individual accounts or contactsinvoice statements, in your organization’s data.

 
public static Database.SaveResult[] update(sObject[] recordsToUpdate, Boolean allOrNone)

The optional allOrNone parameter specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why. If the parameter is not set or is set true, an exception is thrown if the method is not successful.
Ajay K DubediAjay K Dubedi
Hi Nandu,

Here is a solution to your Problem.
    
The (True/False) parameters are optional that specifies whether the operation allows partial success. If you specify false for this parameter and a record fails, the remainder of the DML operation can still succeed. This method returns a result object that can be used to verify which records succeeded, which failed, and why. If the parameter is not set or is set true, an exception is thrown if the method is not successful.
 and for Map, it's by default False.
    
I hope it will help you.
Please select this as Best Answer so that other's also get help from this.
 
Thank You
Ajay Dubedi