+ Start a Discussion
PremInfoPremInfo 

Insert and Fetch UserStatus Feed by FeedItem.

I am not able to fetch and insert the user status feed into feed item.

 

1. SELECT Type FROM FeedItem WHERE Type='UserStatus' returning 0 records even though user status feed is available

2. When I try to create a User Status feed of type FeedItem getting error "User status feed cannot be created directly through feeditem"

 

Please let me know if I am doing any thing wrong here and the right way to get the user status feeds.

 

 

Jia HuJia Hu
User auser = [select id, Alias, CurrentStatus from User where id = :UserInfo.getUserId()];
system.debug(auser);
auser.CurrentStatus = 'new input';
update auser;

Feeditem fi = [Select Body, Type FROM FeedItem WHERE Type='UserStatus' Order by Createddate Desc limit 1];
System.debug(fi);
Jia HuJia Hu
A FeedItem of type UserStatus is automatically created when a user adds a post to update the current status. You can’t explicitly create a FeedItem of type UserStatus.

doc:
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_feeditem.htm