I am writing a trigger to handle after insert,after update and after delete events. I am using trigger.old for after delete.But, how to differentiate the deleted record from the rest of the records of the object?
What I have done so far is :
List<Object__c) lstTriggerOld = trigger.old; List<Object__c> lstAllRecords = [SELECT Id FROM Object__c WHERE ID != NULL]; List<Object__c> deletedRecords = [SELECT Id FROM Object__c WHERE ID IN :lstTriggerOld AND ID NOT IN : lstAllRecords ];
But the last list is not fetching any rows.
Can someone help?