• MarkOCT
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
 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){
    addListItem(header,messageInput,true);
    addListItem(item,messageInput,false);
    //add a blank line
    addListItem('&nbsp;',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);
}

 
I'm stuck on the Modify the NewURLPolicyCondition Apex Class challenge: Modify the NewURLPolicyCondition Apex class you created in an earlier challenge and change its condition from any time in the past two days to the past week.

I completed the previous challenges in this section with ease but don't see any reference to "in the past two days" so I am not sure how to modify the condition "to the past week". 

Please help!