I'm trying to display the feeditems with attachments in VF page.

I'm trying to query the Feeditem using the following query.

SELECT id, ContentFileName, ContentSize, CreatedDate FROM FeedItem WHERE Type = 'ContentPost' AND ParentId ='Sobject Id'

I'm getting the records, no issue. but when I delete the file from the content Document, the post still shows in my Sobject Feeds but it says "file is no longer available". I need to exclude the records from the feeditem whose attachment file is not available in feeditem enter image description here

1 Answer 1


You can't filter ContentFileName, ContentSize, RelatedRecordId in query call according to documentation, but you can skip those files by checking their content size in apex, for e.g

if(ContentSize!=Null && ContentSize > 0)

You must log in to answer this question.

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