+ Start a Discussion

Get feedItems and comments related to new Version of file uploaded in chatter



I am working on a peice of code ,for following scenario -

When i upload a new version of a File on chatter, i want to get all  the  feedItems and comments where this new file version is reflected.

Form the ContentDocument i get the Id of the New file version(i.e ContentVersion Id),

Using this Id when i query on FeedItem and filter on RelatedRecordId i get an error saying


"RelatedRecordId From FeedItem Where RelatedRecordId = '068e00000008ax0AAA' ^ ERROR at Row:1:Column:56 field 'RelatedRecordId' can not be filtered in query call"


Here is my query - Select Id,ParentId,RelatedRecordId From FeedItem Where RelatedRecordId = '068e00000008ax0AAA'


So if i can't filter on RelatedRecordId, then is there an another way to get the feeditem record related to new version?







As per design we can not filter RelateRecordID (reference: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_feeditem.htm). I would suggest you to use IN clause instead of making a filter, as follows:


Select Id,ParentId,RelatedRecordId From FeedItem Where Id IN (Select RelatedRecordId from FeedComment where Condition which can fetch the relatedrecordID


Hope this helps!