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
Venkat adityaVenkat aditya 

I to add a button in case details page, when i click the button i need case age status

Hi,

I have scenario that, 
In case detail page i have to insert a button, that button name is "case age"
When ever i click that button i need to fetch the case status, like eg: when it changes to new to working and working to escalated, 
When ever i click that button it display like case status, case changed date, current status of case in visual force page, 
How can i acheive this, Help with this task,


Thanks in advance,
Aditya
 
Amit Singh 1Amit Singh 1
Hi Aditya,

You can use FeedItem salesforce standard object to track the feed item changes. Below is sample code that I did one of my project.

/* Apex Class */
public with sharing class ChatterHistoryBrowserController {

    public List<OpportunityFeed>feedHistory {get; set;}
    public String month {get; set;}
    public String year {get; set;}
    
    public ChatterHistoryBrowserController(ApexPages.StandardController con) {
        feedHistory = new List<OpportunityFeed>();  
        feedHistory = [SELECT Id, Type,CreatedById, CreatedBy.FirstName, 
        CreatedBy.LastName, CreatedDate,ParentId, Parent.Name, (SELECT Id, FieldName, OldValue, NewValue FROM 
        FeedTrackedChanges ORDER BY Id DESC), 
        (SELECT Id, CommentBody, CreatedDate,CreatedById, CreatedBy.FirstName, 
        CreatedBy.LastName FROM FeedComments ORDER BY CreatedDate ASC, ID DESC LIMIT 10) 
        FROM OpportunityFeed ORDER BY CreatedDate DESC, ID DESC LIMIT 20];
    }
    
    
 
}
/* --------- VF Page --------------*/
<apex:page standardController="Opportunity" extensions="ChatterHistoryBrowserController">
    <div class="pageBlockBox">
    <apex:pageBlock title="Chatter Posts from the Past" id="resultBlock">
        <apex:repeat value="{!feedHistory}" var="f">
               <!-- display the posts -->
               
               <div id="chatterPost">


               <apex:Repeat value="{!f.FeedTrackedChanges}" var="cf">
                          
                        <apex:outputLabel id="comment-repeat"> 
                            
                          changed  {!SUBSTITUTE(cf.FieldName, "Opportunity.", "")} &nbsp; to {!cf.NewValue}
                        </apex:outputLabel>
                        <apex:variable value="{!SUBSTITUTE(cf.FieldName, "Opportunity.", "")}" var="newVar" />
                        <apex:outputlabel >
                            {!$ObjectType.Opportunity.Fields.StageName.Label} 
                        </apex:outputlabel>
                        
               </apex:Repeat>
               
              
               <apex:outputText value=" {0,date,M/d/yyyy h:mm a}" styleClass="dateText">
                  <apex:param value="{!f.CreatedDate}" />
               </apex:outputText>
           
               </div>

        
        </apex:repeat>
    </apex:pageBlock>
    </div>
    <style>
        #chatterPost  {
            -moz-border-radius:5px 5px 5px 5px;
            background:none repeat scroll 0 0 #D1EFF8;
            padding:7px 21px 12px;
            width:500px;
            border:solid 2px #1797C0;
        }
        #chatterComment {
            -moz-border-radius:5px 5px 5px 5px;
            background:none repeat scroll 0 0 #EFF7FA;
            margin-left:40px;
            padding:7px 21px 12px;
            width:460px;  
            border:solid 2px #1797C0;
        }
        #leftFloat {
            float:left;
        }
        .chatterLink {
            color:#1797C0 !important;
            font-weight:bold;
            text-decoration:none;
        }
        .pageBlockBox {
            width:600px;
        }
        .dateText {
            color:#6F6F6F;
            font-size:11px;
        }
    </style>
</apex:page>
Also, refer below link for FeedItem Object.

https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_feeditem.htm
Let me know if this works :)
Thanks!
Amit Singh.