You need to sign in to do that
Don't have an account?
Peter Kaye
Why do deleted items appear in SOQL queries for some objects and not for others ?
Why do some custom objects show deleted items in SOQL queries and others don't ?
I have two SOQL queries for different custom objects both with deleted items ( as seen in the Recycle bin ) and both including the IsDeleted field. Niether query has any WHERE statement. For one object the query retrieves records where IsDeleted = 1 or blank. But for the other object only IsDeleted = blank records show.. Why is this ? Is there some object setting that could explain this. Thanks.
I have two SOQL queries for different custom objects both with deleted items ( as seen in the Recycle bin ) and both including the IsDeleted field. Niether query has any WHERE statement. For one object the query retrieves records where IsDeleted = 1 or blank. But for the other object only IsDeleted = blank records show.. Why is this ? Is there some object setting that could explain this. Thanks.
Great! I've never worked using PHP with Salesforce but looking at your code I can suggest you a test:
Note that the query that does not show the deleted records has And the one that works has
So my best guess is that queryAll implies the use of ALL ROWS keyword. I suggest you to change the other query to use queryAll as well.
Hope to have helped!
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
All Answers
How are you executing this your query? Can you share it?
It sounds weird first because IsDeleted is never blank, either is false (default) or true (when deleted). And second because if you don't use the ALL ROWS keyword is not supposed to show deleted records.
Hope to have helped!
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
Thanks for coming back on this. Yes, you have helped !
The SOQL is executed using the Force.com php toolkit. Here is the php code snippet for the object that fails to show deleted records.
Here is the snippet for the object where deleted records do appear.
Here is the print_r response string showing IsDeleted blank for record 258 and 1 for 259.
..
Maybe I need to look at this data in Eclipse and run the Apex code you have suggested.. I haven't done this so far because I thought there might be a simple explanation !
There is something funny about the custom object that fails to show deleted items. I have 6 other custom objects that do not have this issue. The need to access deleted items is important because I run an hourly program that synchronises SF data with a MySQL db by selecting all SF records with a LastModifiedDate > than a stored value and then deleting and recreating the records in the MySQL db. If I can't pick up deleted records then this approach won't work - I'll need to sort deletions by comparing and Id list between MySQL and SF.
Great! I've never worked using PHP with Salesforce but looking at your code I can suggest you a test:
Note that the query that does not show the deleted records has And the one that works has
So my best guess is that queryAll implies the use of ALL ROWS keyword. I suggest you to change the other query to use queryAll as well.
Hope to have helped!
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.