Documentation Version
Winter '16 (API version 35.0)
  • Winter '16 (API version 35.0) 35.0
  • Summer '15 (API version 34.0) 34.0
  • Spring '15 (API version 33.0) 33.0
  • Winter '15 (API version 32.0) 32.0
  • Summer '14 (API version 31.0) 31.0
  • Spring '14 (API version 30.0) 30.0
  • Winter '14 (API version 29.0) 29.0
  • English


Allows a call to roll back all changes unless all records are processed successfully.

Without the AllOrNoneHeader header, records without errors are committed, while records with errors are marked as failed in the call results. This header is available in API version 20.0 and later.

Even if the header is enabled, it's still necessary to inspect the success field in the call result for each record to identify records with errors. Each success field contains true or false indicating whether the call was processed successfully.

If there is an error associated with at least one record, the errors field in the call result for the record gives more information on the error. If other records in the same call have no errors, their errors fields indicate that they were rolled back due to other errors.


Element Name Type Description
allOrNone boolean If true, any failed records in a call cause all changes for the call to be rolled back. Record changes aren't committed unless all records are processed successfully.

The default is false. Some records can be processed successfully while others are marked as failed in the call results.

Sample Code—Java

This sample shows how to use the AllOrNoneHeader. It attempts to create two contacts. The second contact doesn’t have all required fields set and causes a failure on creation. Next, the sample sets the allOrNone field to true, and then attempts to create the contacts. Creating one of the contacts results in an error, so the entire transaction is rolled back and no contacts are created.
  public void allOrNoneHeaderSample() {
    try {
      // Create the first contact.
      SObject[] sObjects = new SObject[2];
      Contact contact1 = new Contact();
      contact1.setLastName("Van Persie");
      // Create the second contact. This contact doesn't 
      // have a value for the required
      // LastName field so the create will fail.
      Contact contact2 = new Contact();
      sObjects[0] = contact1;
      sObjects[1] = contact2;
      // Set the SOAP header to roll back the create unless
      // all contacts are successfully created.
      // Attempt to create the two contacts.
      SaveResult[] sr = connection.create(sObjects);
      for (int i = 0; i < sr.length; i++) { 
        if (sr[i].isSuccess()) {
          System.out.println("Successfully created contact with id: " + 
            sr[i].getId() + ".");
        else {
          // Note the error messages as the operation was rolled back 
          // due to the all or none header.
          System.out.println("Error creating contact: " + 
          System.out.println("Error status code: " + 
    } catch (ConnectionException ce) {