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? – Jeremy Nottingham May 31 '14 at 13:36

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.