+ Start a Discussion
Will Jones 18Will Jones 18 

Unable to pull OpportunityContactRole deleted records

I am attempting to do a call out to an external server to notify it to remove a contact from an opportunity if it is removed from the contact role on the opportunity in Salesforce. However the query I am attempting to use does not return any records. I attempted to delete a contact from an Opportunity and when I check by debug log I see that my query does not ever return any record. I trigger the opportunity successfully when the opportunitycontactrole is edited/deleted but it doesn't return the record. Any suggestion?
trigger OCR on Opportunity (after insert, after update, after delete) {

List<OpportunityContactRole> ocr_list_del = [SELECT Id, OpportunityId, ContactId, Role, IsPrimary FROM OpportunityContactRole WHERE OpportunityId IN: Trigger.newmap.keyset() AND IsDeleted=true ALL ROWS];

SYSTEM.DEBUG('The OCR Delete List Size is ' + ocr_list_del.size());


I am having the same issue, contacted support about this, will let you know what I hear.  Seems like OpportunityContactRole records skip the recycle bin.
Any updates here? We have been able to use the IsDeleted flag for OCRs in the past and it looks like you can use the getDeleted methods via the api (so they don't always skip the recyle bin).

Is this a recent change?