How to query view setup audit trail using apex in Salesforce?

How to query view setup audit trail using apex in Salesforce?

Starting with Winter’16 the SetupAuditTrail object is exposed to query from Apex.

For fields in the object, check the below link

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_setupaudittrail.htm

Sample SOQL:

List<SetupAuditTrail> listAudits = [SELECT Id, 
Action, 
CreatedBy.Name, 
CreatedDate, 
Display, 
Section 
FROM SetupAuditTrail 
WHERE CreatedBy.Email LIKE ‘%abc.com%’];

Leave a Reply