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
keerthana chowdharykeerthana chowdhary 

Unable to capture SetupAuditTrail data into to custom object fields

public class AUditingBatch implements Database.Batchable<sObject>,Database.Stateful{
public String query;
    public AUditingBatch(){
 query = 'Select Action__c,Display__c,Section__c, CreatedBy__c, CreatedDate__c, DelegateUser__c From AUditTrial__c WHERE CreatedDate__c > YESTERDAY';
    }
public Database.querylocator start(Database.BatchableContext BC){
    
        return Database.getQueryLocator(query);
    }

public void execute(Database.BatchableContext BC, List<AUditTrial__c> scope )
    {
    List<AUditTrial__c> InsrtRecord = new List<AUditTrial__c>(); 
        SetupAuditTrail AU= new SetupAuditTrail();
     for(Sobject s : scope){
     AUditTrial__c obj = (AUditTrial__c) s;
     InsrtRecord.add(new AUditTrial__c(
                   
                   Action=obj .Action__c,
                   //CreatedBy = obj .CreatedBy__c,
                   CreatedDate = obj.CreatedDate__c,
                   //DelegateUser= obj.DelegateUser__c,
                   Display= obj .Display__c,
                   Section= obj .Section__c
               ));
     }
    insert InsrtRecord;
    }
public void finish(Database.BatchableContext BC)
{
    system.debug('JOB IS FINISHED');
  }
}
sfdcsushilsfdcsushil
Whats the erorr?