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?
UPDATE FOR CODE
//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){
addListItem(header,messageInput,true);
addListItem(item,messageInput,false);
//add a blank line
addListItem(' ',messageInput,false);
}
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;
messageInput.messageSegments.add(markupBeginSegment);
ConnectApi.TextSegmentInput textSegment = new ConnectApi.TextSegmentInput();
textSegment.text = item;
messageInput.messageSegments.add(textSegment);
ConnectApi.MarkupEndSegmentInput markupEndSegment = new ConnectApi.MarkupEndSegmentInput();
markupEndSegment.markupType = isHeader? ConnectApi.MarkupType.Bold : ConnectApi.MarkupType.Paragraph;
messageInput.messageSegments.add(markupEndSegment);
}