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
rfgrfg 

Generate a debug log for an Apex class that runs when a report is exported

I'm trying to create an Apex Condition on a Transaction Security Policy. The code runs when a user attempts to export a report. The code I'm trying to modify looks like this:

global class BlockLargeDataExportEventCondition implements TxnSecurity.EventCondition {
    public boolean evaluate(SObject event) {
        switch on event{
            when ReportEvent reportEvent {
                return evaluate(reportEvent);
            }
            when null {
                // Don't take policy action when event is null
                return false;
            }
            when else{
                // Don't take policy action when event is not handled
                return false;
            }
        }
    }
    /**
     * Handle evaluating ReportEvent
     */
    private boolean evaluate(ReportEvent reportEvent){
        Profile profile = [SELECT Name FROM Profile WHERE Id IN
                            (SELECT profileId FROM User WHERE Id = :reportEvent.UserId)];
        // Take policy action only if the user profile is not 'System Administrator' and
        // RowsProcessed greater than 250.
        if (!profile.Name.contains('System Administrator')
            && ReportEvent.Operation.equals ('ReportExported')
            && reportEvent.RowsProcessed > 250) {
            return true;
        }
        return false;
    }
}
But I can't seem to get any debug logs generated, so when I try to `System.debug` my variables (I'm trying to modify this to check for a specific permission set instead of a Profile), I can't see why it's not working. I'm trying to activate a debug log for my User. I get logs for other things my user account does (like edit the Apex class), but no logs are generated when I export a report. Any idea what I'm doing wrong?
Best Answer chosen by rfg
VinayVinay (Salesforce Developers) 
Can you check logs for "Automated Process" User ? and see if you find any logs.

Thanks,

All Answers

VinayVinay (Salesforce Developers) 
Can you check logs for "Automated Process" User ? and see if you find any logs.

Thanks,
This was selected as the best answer
rfgrfg
thank you, that was it!