+ Start a Discussion
ranadheer reddy chaduvuranadheer reddy chaduvu 

How to convert the below trigger to batchclass

trigger preventingdeletion on Apple__c (before delete) {

  for(Apple__C a:[select id,name,(select id from Orange__r ) from Apple__C where id in:Trigger.oldmap.keyset()]){
    Apple__c actualRecord = Trigger.oldMap.get(a.Id);
   actualRecord.adderror('dont delete');


The above trigger is to prevent the parentobjectrecord from deletion if there is any child exists ...Here my parent object is Apple__C,and my child object is Orange__C,,help me ..thanks
Use the approach explained in the below post