You need to sign in to do that
Don't have an account?
Duc Ha 4
SOQL strange behavior
I use Workbench to run some SOQL queries to get data from my ContentDocument table. My first query simply lists all the records:
"Select Id, Title from ContentDocument"
The number of records matchs what's returned by the SOQL API. However, if I select to include "Deleted and Archived Records" from the console, I see a couple more data. I am new to SFDC so this is a bit strange for me. But that wasn't the strangest part - the strangest part is by accident I ran into some DocumentIDs that were NOT included in the table, but if I search for them specifically, Workbench returns them!
"Select Id, Title from ContentDocument where Id=<foo>"
I double-checked several times, using Title and ID so it's not my eyes. Plus there are more than 1 records missing.
So I have 2 questions:
1> What do I need in my SOQL query to get everything from the table? I will only use API for production
2> Why do I not see some records with a statement that should return everything (I come from vanilla SQL camp)?
"Select Id, Title from ContentDocument"
The number of records matchs what's returned by the SOQL API. However, if I select to include "Deleted and Archived Records" from the console, I see a couple more data. I am new to SFDC so this is a bit strange for me. But that wasn't the strangest part - the strangest part is by accident I ran into some DocumentIDs that were NOT included in the table, but if I search for them specifically, Workbench returns them!
"Select Id, Title from ContentDocument where Id=<foo>"
I double-checked several times, using Title and ID so it's not my eyes. Plus there are more than 1 records missing.
So I have 2 questions:
1> What do I need in my SOQL query to get everything from the table? I will only use API for production
2> Why do I not see some records with a statement that should return everything (I come from vanilla SQL camp)?
ContentDocument id has prefix '069'. Do you mean it returns record if your soql in workbench is like this?
select id, title from ContentDocument where id = '001xxxxxxxxxxx' -- prefix 001 is for account object.
if use ALL ROW keyword in your apex code, you can get all records including deleted and archived ones. This keyword won't work in Developer Console.
Or you can use Connection.QueryAll( 'your soql command') to get the same result as All ROW keyword in Java or C#.
On the ALL ROW keyword, I use REST calls so looks like it's not supported. But anyway, the missing records are not deleted (based on isDeleted property).
http://salesforce.stackexchange.com/questions/2206/obtaining-all-contentdocument-records-using-soql