I can query the SetupAuditTrail records but failed to delete some of them. Neither Apex nor the developer console can help me out. Anyone has the gadget to fulfill this mission? Thanks.

List<SetupAuditTrail> s = new List<sObject>();
s.addAll( [ SELECT Id FROM SetupAuditTrail WHERE CreatedDate = TODAY ] );
  • According to the documentation here -- developer.salesforce.com/docs/…, it is not possible to update and/or delete such entries (and that is logical)
    – kurunve
    Mar 29, 2021 at 7:46
  • 1
    Why would you want to do that? Mar 29, 2021 at 8:48
  • Just out of curiosity, part of the local team is trying to earn much more permissions from global team... long story
    – 晓天蔡
    Apr 1, 2021 at 5:14

1 Answer 1


We can't delete the setup audit trail because it supports only two calls query(), retrieve().

Please see documentation to learn more

When you attempt to delete, you will run into the following error

enter image description here

    List<SetupAuditTrail> deleteAuditTrailList = 
    [SELECT Id,
     FROM SetupAuditTrail 
     LIMIT 5];
System.debug('results are' + deleteAuditTrailList);

Delete deleteAuditTrailList;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .