4

First thing that came to my mind was writing a Batch Apex to do this but I get this error.

 System.UnexpectedException: The requested operation is not supported by this SObject

Deleting via Bulk API using Dataloader is not allowed too for some reason.

I only found documentation on this here : https://developer.salesforce.com/docs/atlas.en-us.bigobjects.meta/bigobjects/big_object_delete.htm

but even then I am only able to delete 50000 rows a time otherwise will get the error :

System.LimitException: Too many query rows: 50001

I'm currently running this code in Anonymous Apex :

List<bigobject__b> BO = new List<bigobject__b>(); 

BO.addAll([SELECT Company_Name__c FROM bigobject__b LIMIT 50000]);

Database.deleteImmediate(BO);

Any suggestions how else I can perform this delete quicker and more efficiently?

1 Answer 1

1

I know its an old question, but in future someone might search this for a quick delete of the BigObject records from their org without using a tool.

I designed a solution using a VFPage + RemoteAction.

As the request is from JS, each request is treated as a new request. So it can be triggered multiple times. And the logic break is controlled by the server side boolean parameter.

Controller :

global class DeleteAllBigObject {

    @RemoteAction
    global static Boolean deleteAllBigObject(){
        List<Rider_History__b> cBO = new List<Rider_History__b>();
        List<Rider_History__b> riderHistoryB = [SELECT Rider_Account__c, Start_Time__c FROM Rider_History__b LIMIT 1];
        if(riderHistoryB.isEmpty()){
            return false;
        } else {
            cBO.addAll([SELECT Rider_Account__c, Start_Time__c FROM Rider_History__b LIMIT 49999]);
            Database.deleteImmediate(cBO);
            return true;
        }
    }

}

VFPage:

<apex:page id="HelloWord" controller="DeleteAllBigObject">
    <apex:slds/>
    <script>

        function RemoteActionToDeleteBigObject(){
            Visualforce.remoting.Manager.invokeAction(
                    '{!$RemoteAction.DeleteAllBigObject.deleteAllBigObject}',
                    function(strResult, objEvent){
                        if(strResult){
                            RemoteActionToDeleteBigObject();
                        } else {
                            document.getElementById('DeletionLabel').classList.remove('slds-hide');
                        }
                    },
                    {buffer: false, escape: false, timeout: 120000}
            );
        }

    </script>
    <button onclick="RemoteActionToDeleteBigObject()">Trigger Deletion of Big Object</button>
    <div class="slds-hide" id="DeletionLabel">
        Deletion Done
    </div>
</apex:page>

Just change the bigobject name to your bigObject name, and this code should work fine.

In the else part you can even send an email using remote action.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .