Recipes by Category

App Distribution (2) Bundle logic, interface and services for distribution. App Logic (37) The Apex programming language, workflow and formulas for logic. Collaboration (5) The Salesforce Chatter collaboration platform. Database (29) Data persistence, reporting and analytics. Integration (33) Web Service APIs and toolkits for integration. Security (9) Platform, application and data security. Tools (4) tooling User Interface (36) Visualforce MVC and metadata-drive user interfaces. Web Sites (12) Public web sites and apps with optional user registration and login.
Beta Feedback
Cookbook Home » Update A User's Status on Chatter

Update A User's Status on Chatter

Post by Jon Mountjoy  (2010-07-28)

Status: Unverified
Level: novice


You want to update your Chatter status using either Apex or from within a custom Visualforce page.


User status updates are managed through the CurrentStatus field on the User object. Updating the User.CurrentStatus field also updates the User.CurrentStatusLastModified timestamp, which is used on the People tab, and is displayed on the User Profile page

Here's a Visualforce page that asks for the status:
<apex:inputText value="{!status}" id="status" maxlength="100" /> 
<apex:commandLink style="button" value="Update User Status" action="{!doUserStatus}" />
Here's a custom controller that does the actual update:
public string status     { get; set; }

public PageReference doUserStatus()   {
       User user = [select id, CurrentStatus from User where id = :UserInfo.getUserId()];
       user.CurrentStatus = status;
       update user;
       return null;


Recipe Activity - Please Log in to write a comment

PLEASE REMOVE THIS RECIPE!!!  CurrentStatus was deprecated in API 25.  

by a093000000YI7Bl  (2014-07-11)

i have a question about the function doUserStatus.
Why is its type PageReference ? And Where we use the that class ? I am new at apex programming... 

by CANER ÖZDEN  (2011-02-26)


Vote to Verify a Recipe

Verifying a recipe is a way to give feedback to others and broaden your own understanding of the capabilities on When you verify a recipe, please make sure the code runs, and the functionality solves the articulated problem as expected.

Please make sure:
  • All the necessary pieces are mentioned
  • You have tested the recipe in practice
  • Have sent any suggestions for improvements to the author

Please Log in to verify a recipe

You have voted to verify this recipe.