function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Querying attachments from Java


I am writing a java client that downloads images from Saelsforce attachment object.

I see that the query is building correctly, but still the query results does not give me all attachments in result.


As an example, my query is : Select a.Name, a.ParentId, a.ContentType, a.Body From Attachment a where a.ParentId in ('001M0000002sV43IAE','001M0000002sV2OIAU') order by createddate asc


Here I get attachment only for the first id in query. It does not return me attachment object for 2nd id in query.

If I change the order to ids, I still get attachment associated with 1st id only.

Second id related attachment is always ignored and does not get downloaded as part of query result.


Has anybody faced this issue, is there any hint to solve this problem?


I have one more question.

Can we also store .swf files in attachment? Flash animations.





Yoi have to call queryMore to get the remaining rows (see the done flag and queryLocator string on the queryResult object) the API docs has more info.


Thanks Simon for your reply.

Does that mean attachments are returned only 1 record in a result? There is no way I can read multiple attachments in a single query call (without doing queryMore)?


I guess queryMore is used to get results beyond 500 records where the query returns more than 500 records.





When you query a blob field (like Body on atttachment) results are return 1 row at a time, and you have to call queryMore to iterate over the entire result set.