Want to write an soql query on Accounts and products. If i select Account lookup in visualforce page i want to display history information of that account in table format. I tried to write an soql query where i am unable to get output please some one help me out.

  • Are the products you want to see somehow related to the accounts? Commented May 31, 2014 at 13:36

1 Answer 1


On Account, if you use Setup -> Customize -> Accounts -> Fields -> Set History tracking you can nominate fields for which changes are recorded and query that data like this:

public AccountHistory[] history {
    get {
        return [
                select OldValue, NewValue, IsDeleted, Field,
                        CreatedDate, CreatedById, CreatedBy.Name
                from AccountHistory
                where AccountId = :accountId
                order by CreatedDate desc

But unfortunately this history tracking mechanism is not available for products.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .