• Jared Hagemann
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hi All,

I have created a Global Action and Published in the Chatter Layout. The Action Type of Global Action is Custom Visualforce. The VisualForce page consists of a button when clicked it perform an action to Post some text to the Chatter.
I can able to Post to the Chatter successfully but I have to reload the Window to see my Post. But the window should be automatically reloaded once the button is clicked to show the inserted Post.

Here is the Screenshot of the Chatter with Global Action which consists the VF Page:
User-added image
Here is the VF Page:
<apex:page controller="PracticeClass" >
    <script>
    function refreshPage(){ 
        
        window.location.reload();
    }
    </script>
    
    <apex:form >
        <div align="center" style="margin:100px auto" >
            <apex:inputTextarea  />
            <apex:commandButton value="PostToChatter" action="{!PostToChatter}" onclick="refreshPage()" />            
        </div>
    </apex:form>
</apex:page>

Here is the Controller:
public class PracticeClass {
    
    public void PostToChatter()
    {
        FeedItem post=new FeedItem();
        post.Body= 'Your Feed is Posted 12345';
        post.ParentId= '00528000001KZre';
        insert post;
    }
}

Thanks in Advance,
Mike J