Is it possible to store audit trail information on reports ?if it is possible how can i enable the option allow reports/snapshnot on audit trail and then from reports to custom objects.i know that by using analaytical snapshot we can store reports into custom object


SetupAuditTrail is now a first class sObject. However its reportability is minimal. To me, the most interesting bits to filter on are the Display field (the actual audit message) and the Section field, broadly the type of audit.

Given the history of the Setup Audit Trail object and how it is used traditionally, the decision was taken to not make those fields filterable in SOQL. The object is also not reportable. More on that in a minute.

As part of some explorations around Salesforce Shield, and learning of this new object, I built a little POC component for Dreamforce 15. I wanted to know everything to do with "Encryption" and see all events.

I wound up having to do query of all events in the setup audit trail, then use regex to filter in Apex as follows:

public static List<SetupAuditTrail> getEncryptionAudits(){
    List<SetupAuditTrail> filteredAuditRecords = new List<SetupAuditTrail>();

    Pattern ptn = Pattern.compile('.*[E,e]ncryption.*');

    for (List<SetupAuditTrail> batch : [SELECT Action, Id, Section, CreatedDate, CreatedBy.Name, Display, DelegateUser FROM SetupAuditTrail ORDER BY CreatedDate DESC]){
        for (SetupAuditTrail item : batch) {

            //find if this audit row matches in the Section and Display fields

            Matcher matchSection = ptn.matcher(item.Section != null ? item.Section : '');
            Matcher matchDisplay = ptn.matcher(item.Display != null ? item.Display : '');

            if (matchSection.matches() || matchDisplay.matches()){
        // I was using this to make sure I wasn't banging up against heap limits

    return filteredAuditRecords;


I then piped this into a lightning design system based lightning component:

Setup Audit in Lightning Design System

Ostensibly, this is the poor man's version of the paid-for feature of Event Monitoring that is offered either as its own line-item, or as part of the "Salesforce Shield" bundle.

To extrapolate, you could do something similar with reporting. Look for audit events around the creation and modification of reports, export them on a regular basis, etc. But the setup audit is for setup actions. Running reports will never be tracked here.

Alternatively, you could sign up for the Salesforce event monitoring system, which should track anything that is a potentially suspicious looking use of reporting. One of the profiled behaviors, I think, has to do with how reports are run.

| 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.