+ Start a Discussion

How to show opportunity field history on VF page?



I am using <apex:detail relatedList="false"/> in my VF page.


so i am not able to show a history of opportunity..


I just want to show opportunity history


How can i show that?


i do not know the relationship between the Opportunity and opportunity field history object.



<apex:relatedlist subject="{!Opportunity}" list"___________">


i do not know what to write there?



Any kind of help wiil be greatly appriciated.





Vishal Thoriya.


There is an object that saves Opportunity field history... Try this below SOQL on Opportunity that has a sub query on Opp. field history....


Select (Select Id, IsDeleted, OpportunityId, CreatedById, CreatedDate, Field, OldValue, NewValue From Histories) From Opportunity o

/// Or 

Select o.OpportunityId, o.OldValue, o.NewValue, o.IsDeleted, o.Id, o.Field, o.CreatedDate, o.CreatedById From OpportunityFieldHistory o

Now, use this SOQL and pageBlockTable along with your standard controller to show this grid....


Ashish Kumar YadavAshish Kumar Yadav
Hi all,

Can anyone help me to write inner query in opportunityfieldhistory to fetch the newvalue and oldvalue.
find below query-
SELECT Count(ID),SUM ( HardwareMValue__c) Amount_Added1
FROM Opportunity where Hardware__c = true AND CreatedDate = today
AND OppHis.FromStageName = 'Prospect' and  oppHist.Tostage = 'Close Dropped'