Deletes one or more individual objects from your organization’s data.
DeleteResult[] = binding.delete(ID[] ids);
Use delete() to delete one or more existing objects, such as individual accounts or contacts, in your organization’s data. The delete() call is analogous to the DELETE statement in SQL.
When deleting objects, consider the following rules and guidelines:
Deleting objects involves the following basic steps:
public boolean deleteSample() { // Create an array to hold the IDs of the records to delete and add IDs // to the array ID[] ids = new ID[] { new ID("001x00000000JerAAE"), new ID("001x00000000JesAAE") }; // Invoke the delete call try { DeleteResult[] deleteResults = binding.delete(ids); // Process the results for (int i=0;i<deleteResults.length;i++) { DeleteResult deleteResult = deleteResults[i]; // Determine whether delete succeeded or had errors if (deleteResult.isSuccess()) { // Get the id of the deleted record deleteResult.getId(); } else { // Handle the errors. We just print the first error out for sample purposes. Error[] errors = deleteResult.getErrors(); if (errors.length > 0) { System.out.println("Error code: " + errors[0].getStatusCode()); System.out.println("Error message: " + errors[0].getMessage()); } } } } catch (UnexpectedErrorFault e) { System.out.println("Unexpected error encountered:\n\n" + e.getExceptionMessage()); return false; } catch (RemoteException e) { System.out.println("Remote exception encountered:\n\n" + e.getMessage()); return false; } return true; }
private void deleteAccount() { // Delete call takes a string array of IDs as parameter String[] IDs = new String[] {"001x00000000JerAAE"}; // Invoke the delete call, saving the result in a DeleteResult object DeleteResult[] deleteResults = binding.delete(IDs); // Determine whether the delete call succeeded or failed if (deleteResults[0].success) { // Delete operation succeeded System.Diagnostics.Trace.WriteLine("Deleted: " + deleteResults[0].id); } else { // Delete operation failed System.Diagnostics.Trace.WriteLine("Could not delete because: "+ deleteResults[0].errors[0].message); } }
| Name | Type | Description |
|---|---|---|
| ids | ID[] | Array of one or more IDs associated with the objects to delete. In version 7.0 and later, you can pass a maximum of 200 object IDs to the delete() call. In version 6.0 and earlier, the limit is 2,000. |