Use deleteByExample() to delete big object data from your org using an sObject as a template for what to delete. All data in a big object matching the values in the sObject templates are deleted.
When deleting data, consider the following rules and guidelines:
Your client application must be logged in with sufficient access rights to delete individual objects within the specified object. For more information, see Factors that Affect Data Access.
You can’t delete records for multiple object types in one call if one of those types is related to a feature in the Setup area in Salesforce. The only exceptions are the following objects:
Custom settings objects, which are similar to custom objects. For more information, see Create Custom Settings in Salesforce Help.
GroupMember
Group
User
Basic Steps for Deleting Data
Deleting data involves these basic steps.
Define an sObject using all the fields that make up the index of the big object.
Specify the values for each field.
Call deleteByExample(), passing in the sObject you created.
Process the results in the DeleteByExampleResult[] to verify whether the records have been successfully deleted.
Repeating a successful deleteByExample() operation results in success, even if the data has already been deleted.
Note
Sample Code—Custom Big Objects
This sample shows how to delete records in a custom big object. In this example, Account__c, Game_Platform__c, and Play_Date__c are part of the custom big object’s index. All rows where Account__c is “001d000000Ky3xIAB”, Game_Platform__c is “iOS”, and Play_Date__c is “2017-11-28T19:13:36.000z” are deleted.
1public static void main(String[] args){2 try{3 //Declare an sObject that has the values to delete4 sObject[] sObjectsToDelete = new sObject[1];5 sObject[] customerBO = new sObject();6 customerBO.setType("Customer_Interaction__b");7 customerBO.setField("Account__c","001d000000Ky3xIAB");8 customerBO.setField("Game_Platform__c","iOS");9 customerBO.setField("Play_Date__c","2017-11-28T19:13:36.000z");10 sObjectsToDelete[0] = customerBO;1112 DeleteByExampleResult[]result = connection.deleteByExample(sObjectsToDelete);13}14}
Sample Code—Field Audit Trail
This sample shows how to delete records in FieldHistoryArchive. All rows with the specified criteria are deleted.
1public static void main(String[] args){2 try{3 //Declare an sObject that has the values to delete4 sObject[] sObjectsToDelete = new sObject[2];5 sObject[] fieldHistoryArchive_1 = new sObject();6 fieldHistoryArchive_1.setType("FieldHistoryArchive");7 fieldHistoryArchive_1.setField("FieldHistoryType","Account");8 fieldHistoryArchive_1.setField("ParentId","001d000000Ky3xIAB");9 fieldHistoryArchive_1.setField("CreatedDate","2017-11-28T19:13:36.000z");10 fieldHistoryArchive_1.setField("HistoryId","017D000000ESURXIA5");11 sObjectsToDelete[0] = fieldHistoryArchive_1;1213 sObject[] fieldHistoryArchive_2 = new sObject();14 fieldHistoryArchive_2.setType("FieldHistoryArchive");15 fieldHistoryArchive_2.setField("FieldHistoryType","Account");16 fieldHistoryArchive_2.setField("ParentId","001d000000Ky3xIAB");17 fieldHistoryArchive_2.setField("CreatedDate","2017-11-29T19:13:36.000z");18 fieldHistoryArchive_2.setField("HistoryId","017D000000ESURMIA5");19 sObjectsToDelete[1] = fieldHistoryArchive_2;2021 DeleteByExampleResult[]result = connection.deleteByExample(sObjectsToDelete);22}23}
Arguments
Name
Type
Description
sObject
sObject[]
Array of one or more sObjects to use as templates for deletion.