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
protoguyprotoguy 

Is it possible to find out the history of transitions for an opportunity?

Hi - I'm wondering if it's possible to query for the _history_ of an opportunity. That is, if it's Stage is Closed, I'd like to know when it progressed through each of the stages...

Does that make sense? Thanks in advance for your help!
Byron
SuperfellSuperfell
Does the OpportunityHistory object have the data you want ?
protoguyprotoguy
Hi - thanks.

so the fields available here don't include the LastModifiedDate field: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_opportunityhistory.htm

seem to suggest that you can't find out when the status of the deal changed, but if you look at it on SF.com under Opportunity, then you can see a "Last Modified" date which appears to show when the status/ stage changed.

I also see that in the DescribeSObject that it seems like the LastModifiedDate should be queryable from OpportunityHistory.

Anyway, here's the query I made (on a Dev test account):
"Select Amount, CloseDate, ExpectedRevenue, ForecastCategory, ID, LastModifiedDate,
Probability, StageName From OpportunityHistory Where OpportunityID= '006500000085r8GAAQ'"

The error I get is a 'no such field error'.

Lastly, I should offer that what I'm trying to do is gather the data to do some historical analysis on average time spent in stages of deals, and the actual progression statistics to better calculate expected revenue for dealstages based on results. Thanks!
protoguyprotoguy
Scratch the "should be queryable" from the DescribeSObject... that was a bug on my side.

It looks like CreatedDate will give me what I'm looking for and marks when the opportunity changed. tks!
SuperfellSuperfell
LastModified date on Opportunity will change any time there's a change in the opportunity, not just stage.

There's a row in OpportunityHistory for each change of the opportunityStage on the Opportunity. The created date column in the OpportunityHistory table indicates when that particular row was created (and therefore when this change to the opportunity was made). This would seem to be exactly what you're looking for.

When i do describe on OpportunityHistory, i see no LastModifiedDate field.
lithe911lithe911
Simon - I don't think this is entirely correct because I'm trying to do the same thing and finding some odd behavior.  The CreatedDate on the opportunity history record is supposed to be the date a change was made to the opportunity.  However if you change the forecast category of a particular stage value, it actually updates the opportunity history created date to the date you changed the forecast category!  Follow that?  :)

For example, I updated an opportunity stage last week to "Proposal" which at the time was in a Pipeline forecast category.  Today I changed that stage's category to Best Case and now the history record's created date shows today instead of last week!  I've looked at this for two hours and was sure I was seeing things, but there it is.

I'm beginning to think it's not possible to pull an accurate history if sales processes are being revised.

Mark