+ Start a Discussion

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()];
auser.CurrentStatus = 'new input';
update auser;

Feeditem fi = [Select Body, Type FROM FeedItem WHERE Type='UserStatus' Order by Createddate Desc limit 1];
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.