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

Chatter action not refreshing feed?

 I can not seem to get my chatter feed to refresh upon a post being inserted from apex code. I have created a global action that is a visualforce page. I add this to the Global Publisher Layout. Then in chatter I enter some info into the page I built, I format it in my controller and post it to chatter. Everything works as it should, except the feed doesn't update until I manually refresh the page. Does anyone know a way to make an action used in chatter refresh the chatter feed, or whole page?
//called from visualforce page
public PageReference insertIntoFeed() {
   ConnectApi.FeedItemInput input = new ConnectApi.FeedItemInput();
   input.subjectId = 'me';
   input.feedElementType = ConnectApi.FeedElementType.FeedItem;
   ConnectApi.MessageBodyInput messageInput = new ConnectApi.MessageBodyInput();
   messageInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();

   addElement('Field One','line one',messageInput);
   addElement('Field Two','line two',messageInput);

   input.body = messageInput;
   ConnectApi.ChatterFeeds.postFeedElement(null, input);

   return null;

private void addElement(String header, String item,ConnectApi.MessageBodyInput messageInput){
    //add a blank line

private void addListItem(String item,ConnectApi.MessageBodyInput messageInput,Boolean isHeader){
    ConnectApi.MarkupBeginSegmentInput markupBeginSegment = new ConnectApi.MarkupBeginSegmentInput();
    markupBeginSegment.markupType = isHeader? ConnectApi.MarkupType.Bold : ConnectApi.MarkupType.Paragraph;

    ConnectApi.TextSegmentInput textSegment = new ConnectApi.TextSegmentInput();
    textSegment.text = item;

    ConnectApi.MarkupEndSegmentInput markupEndSegment = new ConnectApi.MarkupEndSegmentInput();
    markupEndSegment.markupType = isHeader? ConnectApi.MarkupType.Bold : ConnectApi.MarkupType.Paragraph;