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
mcowgermcowger 

Bad Filter for NewsFeed?

Hi,

 

I'm trying to develop something quick to pull some FeedPosts and am looking at the Recipes provided.  The SOQL for pulling all your items specifies the following in the WHERE claus:

 

AND FeedPost.Body != ''

 

However, if I include that in my SOQL call below

 

 

query = "SELECT Id, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, FeedPost.Body FROM NewsFeed WHERE CreatedById != '" + id + "' ORDER BY CreatedDate DESC, ID DESC LIMIT 20"

 

I get an error:

 

 

MALFORMED_QUERY: Illegal filter on NewsFeed

 

I actually get this anytime I try to filter on any part of the 'FeedBody' Object.  Thoughts/Ideas?  It is important to me to be able to filter on the Body (so that I can filter out Posts that are only Links, etc).

 

 

 

Message Edited by mcowger on 03-31-2010 09:31 PM
cloudcodercloudcoder

The following query works fine for me:

SELECT Id, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, FeedPost.Body FROM NewsFeed  WHERE CreatedById != '005A0000000h8xdIAA' AND FeedPost.Body != '' ORDER BY CreatedDate DESC, ID DESC LIMIT 20

Do you have 'with sharing' on your class definition by any chance?

 

rwoollenrwoollen

If you want just text posts, then "WHERE Type = 'TextPost'"  would do it and is more efficient than filtering on the Body. 

 

The current values for Type are:  TrackedChange, UserStatus, TextPost, ContentPost, and LinkPost.