You need to sign in to do that
Don't have an account?
fiona gentry
Trigger for LookUp not working
Hi,
I have a requirement Whenever HiringManager record is deleted,want to delete the Position as well ,Both HiringManager(Parent) and Position(Child) are custom objects,Position having lookup with HiringManager
In essence i cant make this relationship of HiringManager(Parent) and Position(Child) like master detail but i want to achieve the functionity like whenever parent is deleted child should also get deleted
here is trigger code
Can you suggest what is goin wrong on above trigger
Regards
Fiona
I have a requirement Whenever HiringManager record is deleted,want to delete the Position as well ,Both HiringManager(Parent) and Position(Child) are custom objects,Position having lookup with HiringManager
In essence i cant make this relationship of HiringManager(Parent) and Position(Child) like master detail but i want to achieve the functionity like whenever parent is deleted child should also get deleted
here is trigger code
trigger DeleteChild on HiringManager__c (before delete) { if(Trigger.isBefore && Trigger.isDelete){ List<Position__c> lstPostns = [Select id,HiringManager__r.Name From Position__c Where id IN : Trigger.OldMap.KeySet() ]; if(!lstPostns.isEmpty()){ for(Position__c postns : lstPostns) { postns.id = null; } upsert lstPostns; } } }
Can you suggest what is goin wrong on above trigger
Regards
Fiona
Try Below Code Please Mark It As Best Asnwer If It Helps
Thank You!