getDeleted(String, Datetime, Datetime) Returns the list of individual records that have been deleted for an sObject type within the specified start and end dates and times and that are still in the Recycle Bin.

merge(sObject, Id) Merges the specified duplicate record into the master sObject record of the same type, deleting the duplicate, and reparenting any related records. Merges only accounts, contacts, or leads.

merge(sObject, sObject) Merges the specified duplicate sObject record into the master sObject of the same type, deleting the duplicate, and reparenting any related records.

merge(sObject, List<Id>) Merges up to two records of the same sObject type into the master sObject record, deleting the others, and reparenting any related records.

merge(sObject, List<SObject>) Merges up to two records of the same object type into the master sObject record, deleting the others, and reparenting any related records.

merge(sObject, Id, Boolean) Merges the specified duplicate record into the master sObject record of the same type, optionally returning errors, if any, deleting the duplicate, and reparenting any related records. Merges only accounts, contacts, or leads.

merge(sObject, sObject, Boolean) Merges the specified duplicate sObject record into the master sObject of the same type, optionally returning errors, if any, deleting the duplicate, and reparenting any related records.

merge(sObject, List<Id>, Boolean) Merges up to two records of the same sObject type into the master sObject record, optionally returning errors, if any, deleting the duplicates, and reparenting any related records.

merge(sObject, List<SObject>, Boolean) Merges up to two records of the same object type into the master sObject record, optionally returning errors, if any, deleting the duplicates, and reparenting any related records.

upsert(sObject, Schema.SObjectField, Boolean) Creates a new sObject record or updates an existing sObject record within a single statement, using a specified field to determine the presence of existing objects, or the ID field if no field is specified.

upsert(sObject[], Schema.SObjectField, Boolean) Creates new sObject records or updates existing sObject records within a single statement, using a specified field to determine the presence of existing objects, or the ID field if no field is specified.

convertLead(Database.LeadConvert, Boolean)

Converts a lead into an account and contact, as well as (optionally) an opportunity.

Signature

Parameters

The optional opt_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.

Signature

Parameters

The optional opt_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.

Signature

Parameters

The optional opt_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.

Signature

Parameters

The optional opt_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.

Signature

Parameters

The optional opt_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.

Signature

Parameters

The optional opt_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.

Signature

Parameters

Return Value

Usage

Note the following:

After records are deleted using this method they cannot be undeleted.

Only 10,000 records can be specified for deletion.

The logged in user can delete any record that he or she can query in their Recycle Bin, or the recycle bins of any subordinates. If the logged in user has “Modify All Data” permission, he or she can query and delete records from any Recycle Bin in the organization.

Cascade delete record IDs should not be included in the list of IDs; otherwise an error occurs. For example, if an account record is deleted, all related contacts, opportunities, contracts, and so on are also deleted. Only include the Id of the top level account. All related records are automatically removed.

Deleted items are added to the number of items processed by a DML statement, and the method call is added to the total number of DML statements issued. Each executed emptyRecycleBin method counts against the governor limit for DML statements.

Signature

Parameters

Return Value

Usage

Note the following:

After an sObject is deleted using this method it cannot be undeleted.

Only 10,000 sObjects can be specified for deletion.

The logged-in user can delete any sObject that he or she can query in their Recycle Bin, or the recycle bins of any subordinates. If the logged-in user has “Modify All Data” permission, he or she can query and delete sObjects from any Recycle Bin in the organization.

Do not include an sObject that was deleted due to a cascade delete; otherwise an error occurs. For example, if an account is deleted, all related contacts, opportunities, contracts, and so on are also deleted. Only include sObjects of the top level account. All related sObjects are automatically removed.

Deleted items are added to the number of items processed by a DML statement, and the method call is added to the total number of DML statements issued. Each executed emptyRecycleBin method counts against the governor limit for DML statements.

Signature

Parameters

Return Value

Usage

Note the following:

After an sObject is deleted using this method it cannot be undeleted.

Only 10,000 sObjects can be specified for deletion.

The logged-in user can delete any sObject that he or she can query in their Recycle Bin, or the recycle bins of any subordinates. If the logged-in user has “Modify All Data” permission, he or she can query and delete sObjects from any Recycle Bin in the organization.

Do not include an sObject that was deleted due to a cascade delete; otherwise an error occurs. For example, if an account is deleted, all related contacts, opportunities, contracts, and so on are also deleted. Only include sObjects of the top level account. All related sObjects are automatically removed.

Deleted items are added to the number of items processed by a DML statement, and the method call is added to the total number of DML statements issued. Each executed emptyRecycleBin method counts against the governor limit for DML statements.

executeBatch(Object)

Submits a batch Apex job for execution corresponding to the specified class.

Signature

publicstaticID executeBatch(Object batchClassObject)

Parameters

Return Value

Usage

When calling this method, Salesforce chunks the records returned by the start method of the batch class into batches of 200, and then passes each batch to the execute method. Apex governor limits are reset for each execution of execute.

Return Value

Usage

The value for scope must be greater than 0.

If the start method of the batch class returns a Database.QueryLocator, the scope parameter of Database.executeBatch can have a maximum value of 2,000. If set to a higher value, Salesforce chunks the records returned by the QueryLocator into smaller batches of up to 200 records. If the start method of the batch class returns an iterable, the scope parameter value has no upper limit; however, if you use a very high number, you may run into other limits.

Signature

Parameters

The optional opt_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.

Signature

Parameters

The optional opt_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.

Return Value

Usage

Each executed merge method counts against the governor limit for DML statements.

merge(sObject, Id, Boolean)

Merges the specified duplicate record into the master sObject record of the same type, optionally returning errors, if any, deleting the duplicate, and reparenting any related records. Merges only accounts, contacts, or leads.

Each executed query method counts against the governor limit for SOQL queries.

rollback(System.Savepoint)

Restores the database to the state specified by the savepoint variable. Any emails submitted since the last savepoint are also rolled back and not sent.

Signature

publicstatic Void rollback(System.Savepoint sp)

Parameters

sp

Type: System.Savepoint

Return Value

Type: Void

Usage

Note the following:

Static variables are not reverted during a rollback. If you try to run the trigger again, the static variables retain the values from the first run.

Each rollback counts against the governor limit for DML statements. You will receive a runtime error if you try to rollback the database additional times.

The ID on an sObject inserted after setting a savepoint is not cleared after a rollback. Create new a sObject to insert after a rollback. Attempting to insert the sObject using the variable created before the rollback fails because the sObject variable has an ID. Updating or upserting the sObject using the same variable also fails because the sObject is not in the database and, thus, cannot be updated.

setSavepoint()

Returns a savepoint variable that can be stored as a local variable, then used with the rollback method to restore the database to that point.

Signature

publicstatic System.Savepoint setSavepoint()

Return Value

Type: System.Savepoint

Usage

Note the following:

If you set more than one savepoint, then roll back to a savepoint that is not the last savepoint you generated, the later savepoint variables become invalid. For example, if you generated savepoint SP1 first, savepoint SP2 after that, and then you rolled back to SP1, the variable SP2 would no longer be valid. You will receive a runtime error if you try to use it.

References to savepoints cannot cross trigger invocations because each trigger invocation is a new trigger context. If you declare a savepoint as a static variable then try to use it across trigger contexts, you will receive a run-time error.

Each savepoint you set counts against the governor limit for DML statements.

Signature

Parameters

The optional opt_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.

Signature

Parameters

The optional opt_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.

Signature

Parameters

The optional opt_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.

Signature

Parameters

The optional opt_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.

Signature

Parameters

The optional opt_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.

Signature

Parameters

The optional opt_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.

Return Value

Usage

Apex classes and triggers saved (compiled) using API version 15.0 and higher produce a runtime error if you assign a String value that is too long for the field.

Each executed update method counts against the governor limit for DML statements.

upsert(sObject, Schema.SObjectField, Boolean)

Creates a new sObject record or updates an existing sObject record within a single statement, using a specified field to determine the presence of existing objects, or the ID field if no field is specified.

Parameters

The external_ID_Field is of type Schema.SObjectField, that is, a field token. Find the token for the field by using the fields special method. For example, Schema.SObjectField f = Account.Fields.MyExternalId. The external_ID_Field parameter is the field that upsert() uses to match sObjects with existing records. This field can be a custom field marked as external ID, or a standard field with the idLookup attribute.

The optional opt_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.

upsert(sObject[], Schema.SObjectField, Boolean)

Creates new sObject records or updates existing sObject records within a single statement, using a specified field to determine the presence of existing objects, or the ID field if no field is specified.

Parameters

The external_ID_Field is of type Schema.SObjectField, that is, a field token. Find the token for the field by using the fields special method. For example, Schema.SObjectField f = Account.Fields.MyExternalId. The external_ID_Field parameter is the field that upsert() uses to match sObjects with existing records. This field can be a custom field marked as external ID, or a standard field with the idLookup attribute.

The optional opt_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.