function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
radanradan 

Not able to programatically delete Custom Resources

I am trying to delete some existing Custom Resource records using Apex. Here the custom Resource is called AcField

The fragment of code:

-------

       //blowing off all existing custom resources 

     Map<string,AcField__C> cfCurrMap = AcField__C.getAll(); //get all existing records 

     Set<string> existingCRs = cfCurrMap.keySet(); 

     List<AcField__C> existingL =  new List<AcField__C>();

     for (string ex: existingCRs) { //add to list to delete 

     existingL.add(cfCurrMap.get(ex));

     }

//delete any 

     if (existingL.size() > 0) {

     delete existingL;

    

--------- 

The resulting behavior is inconsistent. Some times a subset of records get deleted, sometimes no records get deleted.

Could some one point out what the issue is?

 

Thanks