function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GunishGunish 

Access to Setup Audit Trail via APEX / Webservice API

Hello,

 

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.

 

 

sfdcfoxsfdcfox

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.

Kirill_YunussovKirill_Yunussov
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,
        Action,
        CreatedBy.Name,
        CreatedDate,
        Display,
        Section 
     FROM SetupAuditTrail 
     WHERE CreatedBy.Email LIKE '%xyzconsulting.com%'];