Activity Forums Salesforce® Discussions How can we find the deleted records in After delete trigger in Salesforce?

  • PRANAV

    Member
    March 20, 2018 at 2:31 pm

    Hi Kapil,

    To get or Query deleted records you need to use ALL ROWS So your query will be

    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 ALL ROWS];

    Hope this helps you.

  • Parul

    Member
    September 18, 2018 at 1:46 pm

    Hi Kapil,

    To Query Record in "afterdelete" Trigger,We have to use Trigger.Old

    i.e. List<SObject> listofsObject = Trigger.Old;

    Thanks

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos