+ Start a Discussion

Access to Setup Audit Trail via APEX / Webservice API



I have been looking for a way to access the setup audit trail programatically, using apex or webservice api. But without any luck. 

Is there a way to achieve this.. 


Maybe by using some URL Tricks ?


The basic requirement is to get a list of all the actions performed by a user in a given time (as displayed in the setup audit trail). It would be great if I could simply query that from some Table ?


Any Ideas , Leads, Comments please.




You can't query this table directly, although you could, if you were so inclined, use a PageReference to the link and call the getContent function. This should allow you to retrieve the contents of the audit trail as a CSV. I'm not entirely sure how reliable this method would be, but in lieu of a standard API, your options are fairly limited. And you would have to process each row instead of filtering by user.

four years later - still nothing?
Ashutosh LAshutosh L
Vote for this Idea:   https://success.salesforce.com/ideaView?id=08730000000glm9AAA
Andy In The CloudAndy In The Cloud
Starting with Winter'16 the SetupAuditTrail object (https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_setupaudittrail.htm) has now been exposed via the Salesforce API's and within Apex via SOQL. Its pretty much a mirror of the CSV download, accept for the Delegate User (though since this is documented, this could be a bug or something i'm missing). The following is a sample query from my latest blog (http://andyinthecloud.com/2015/10/18/setup-audit-trail-api-in-winter16/) where i dig into it a little further...

List<SetupAuditTrail> stuffDoneByConsultants = 
    [SELECT Id,
     FROM SetupAuditTrail 
     WHERE CreatedBy.Email LIKE '%xyzconsulting.com%'];