
1 réponse

Hi Neela,You can write trigger on Contact for before delete event for this case.Please refer the below code. Change the sObject fields to your Own Custom Object fieldstrigger DontDeleteContact on Contact (before delete) { list<Id> ConId = new list<Id>(); map<Id, List<sObject>> IDListMap = new map<Id, List<sObject>>(); for(Contact C : Trigger.Old){ ConId.add(C.Id); } for(sObject s : [select id, name, contact__c from sObject where contact__c IN :ConId order by contact__c]){ for(Contact C : Trigger.Old){ if(C.Id == s.contact__c){ c.addError('Contact have an existing related record. Hence it can not be deleted'); } } }}Please let me know if it works.Please mark it as the solution if it helped you.Thanks,Jainam Contractor,Salesforce ConsultantVarasi LLCwww.varasi.com