Following the answer on this question, I had been using SELECT Id, isDeleted, masterRecordId FROM Contact WHERE masterRecordId != '' and adding AND SystemModStamp > [the last time we checked] with the SOAP API for several years with good results.

Recently I've noticed that this query never returns any results, both in the application that sends the query to the SOAP API and within the Salesforce developer console itself. I've run it with and without the SystemModStamp. I've run it immediately after running a merge, thinking maybe it had just already been deleted by the system. The record is still in the recycle bin, in any case.

I'm wondering if this query no longer works, but the documentation about the field doesn't seem to have changed. I'm not aware of anything that has changed in our Salesforce installation that would've prevented us from being able to detect this, but I'm not really sure what would be able to do that either. Does anyone have any insight into this?

Ideally I'd like to detect merges with the REST API, but as far as I can tell it still does not have a way to detect merges, hence my use of the SOAP API.

  • Do you have ALL ROWS specified in the SOQL? May 5, 2022 at 17:17
  • I didn't before so I just added it, but it does not seem to have any effect. I'm still not getting any merge results. Here's the modified query as it just ran, right after merging a relevant contact in Salesforce: SELECT Id, isDeleted, masterRecordId FROM Contact WHERE masterRecordId != '' AND SystemModStamp > 2022-05-05T17:38:25Z ALL ROWS May 5, 2022 at 17:42
  • Oh, it was already using a method in the soap library called queryAll so I think it was already using ALL ROWS. May 5, 2022 at 17:50
  • What happens if you replace the masterRecordId portion with isDeleted = TRUE? May 8, 2022 at 17:53

1 Answer 1


It turns out my trouble was caused by two different problems:

  1. The Salesforce developer console does not, under any circumstances as far as I can tell, allow a SOQL query to return merged results. So in there the query is always empty.
  2. In my code, I had at some point recently introduced a bug in the code I was using to calculate the value for SystemModStamp.

So ultimately neither of these is related to the Salesforce merge query, which still seems to work as it always did once that date value is calculated correctly (or removed).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .