+ Start a Discussion
KMK91KMK91 

In lookup if we delete parent record then automatically child records sholud be delete as client requirement how?without coding?

Best Answer chosen by KMK91
KaranrajKaranraj
I'm afraid without coding you can't do that. If you want to do that using code then you have to write trigger code on before delete operation 
 
trigger onParentObjectDelete on CustomObject__c (before delete){
List<Id> idsToQuery = new List<Id>{};
for(CustomObject__c a: Trigger.new){
    idsToQuery.add(a.id);
 }

//query all child records where parent ids were deleted
ChildObject__c[] objsToDelete = [select id from ChildObject__c where ParentId__c IN :idsToQuery];

delete objsToDelete; //perform delete statement
}

 

All Answers

KaranrajKaranraj
I'm afraid without coding you can't do that. If you want to do that using code then you have to write trigger code on before delete operation 
 
trigger onParentObjectDelete on CustomObject__c (before delete){
List<Id> idsToQuery = new List<Id>{};
for(CustomObject__c a: Trigger.new){
    idsToQuery.add(a.id);
 }

//query all child records where parent ids were deleted
ChildObject__c[] objsToDelete = [select id from ChildObject__c where ParentId__c IN :idsToQuery];

delete objsToDelete; //perform delete statement
}

 
This was selected as the best answer
KMK91KMK91
I have doubt delete event available only on trigger.old and oldMap,but you wrote trigger.new Is it correct