You need to sign in to do that
Don't have an account?
question on downloading/querying opportunity history
I am using the 4.0 version of the API. I am trying to retrieve history data for an opportunity (i.e. changes to the close date, changes to the amount, etc.) I see there is an OpportunityHistory object available and I downloaded that data to a SQL table. My program does not end with any errors.
I went into salesforce.com and changed the close date on an opportunity. Should the history of that change be reflected in the OpportunityHistory object? I thought it would but I do not see the history of my change in the data I queried. If that is not the correct place to find that data, where can I find the old close date for that opportunity and download it.
Thank you.
Hi drk,
Hmm...
I just tried that using the SOQL tester to run my queries and changing the close date definitely create a new opp history record. Not every change to the opp will result in a new opp history record. From the product documentation:
The Stage History related list of an opportunity detail page tracks the changes in status for that opportunity. Any time you change the Amount, Probability, Stage, or Close Date for the opportunity, a new entry is added to the list with the name of the person that made the change and a date stamp.
My query was simply Select Id, CloseDate, OpportunityId from OpportunityHistory where OpportunityId = '00630000000h8df'.
Are you including more criteria that might be excluding the history?
thank you for your response.
my query that extract data from the tables has no where clause at all so I'm assuming that it will get all data.
"select amount, closedate, expectedRevenue,forecastCategory,opportunityId,probability,StageName,createdById,CreatedDate from OpportunityHistory"
I see my change in salesforce in the stage history area. What is interesting is that the extract data shows all of the history records except for the last two which were entered by a user ID which is different from the first 5 changes.
Could there be some bad data stopping those records from being downloaded - although, my program is not ending with any errors
So, the way the query works is that it will return n records where n is either the default of 2000 or a user specified value up to 2000. You specify the batch size using the queryOptions SOAP header.
Anyway, if the results contain more than 2000 or what ever your batch size has been set to (this is indicated in the size property of the QueryResult object) then to obtain the rest of the records, you would call the QueryMore method passing the queryLocator value on the QueryResult object. You can do this until the QueryResult object returns true on the Done property.
So, yes there is a limit, but it is a batch limit that you can control. The pattern for retrieving all the records is roughly:
bool isMore = true
QueryResult qr = query("Select...")
if (qr.Size > 0)
while isMore
for i = 0 to qr.records.length
process record
next
if (qr.done = true)
isMore = false
else
qr = queryMore(qr.queryLocator)
end if
loop
end if