+ Start a Discussion

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 



//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?