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
Vishal_ThoriyaVishal_Thoriya 

How to show opportunity field history on VF page?

Hi,

 

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.

 

 

Thanks,

 

Vishal Thoriya.

bvramkumarbvramkumar

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'