• manasa gundars 11
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 1
    Replies
DeleteDMl class
public class DeleteDml {
    public void accountInserting(){
        //fetching old records with name kanus
        List<Account> accounts =[SELECT id,name from Account WHERE name='kanus'];
        try{
        delete accounts;
        }catch(Exception e){
            system.debug('records are not deleted');
            
        }
    }
}

testclass
@istest
public class DeleteDML_test {
    public static testMethod Account insertingAccount(){
        test.startTest();
        Account a = new Account();
        a.Name='kanus';
        insert a;
        DeleteDml d = new DeleteDml();
        d.accountInserting();
        Test.stopTest();
        return a;
       
    }
    public static testMethod void Method2(){
      Test.startTest();
        Account a1=insertingAccount();
        Account a2=[SELECT id,name FROM Account WHERE name='kanus123'];
        try{
            delete a2;
        }catch(Exception e){
            system.debug('no record with name kanus123');
        }
        
        test.stopTest();
         DeleteDml d1 = new DeleteDml();
        d1.accountInserting();
    }
}
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