Activity Forums Salesforce® Discussions How to track a field history of a custom object via Api?

  • Rachit

    Member
    August 11, 2016 at 8:21 am

    Hi,

    We can query custom object history in apex and if we use a web service method where we are querying the field history then we can use this in our logic to implement some apex code.Hope this makes sense.

    Thanks

  • PRANAV

    Member
    January 15, 2018 at 12:14 pm

    Hi Tanu,

    You can take the help of sobject history in your apex and built a query matching the sobject id with the related id field in history.

    Exapmle : If you want to track field history of Account object, you can use

    SELECT AccountId,CreatedById,CreatedDate,Field,Id,IsDeleted,NewValue,OldValue FROM AccountHistory

    Similarly If you want to query field history of custom objects, you have to match the parent id of history query with the custom object id.

    Example: If you want to track field history of Phase custom object, you can use

    SELECT CreatedById,CreatedDate,Field,Id,IsDeleted,NewValue,OldValue,ParentId FROM Phase__History

    Hope this helps you.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos