You need to sign in to do that
Don't have an account?
keerthana 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');
}
}
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');
}
}
sfdcsushil
Whats the erorr?