I am developing an application in which i am retrieving records from an object and then want to insert (some of the fields of the) records into different objects. Below is my code in which i cannot figure it out that why my objects are not being populated and new record cannot be seen .
// Scheduler related class 1
public with sharing class ScheduleBatchLauncher{
public static String scheduleBatch(Datetime batchTime){
CreateAndModifyScheduler batchSched = new CreateAndModifyScheduler();
String cron = '20 25 * * * ?';
String schedId = System.schedule('Create and Modify Batch 1', cron, batchSched);
return schedId;
}
}
// Scheduler related class 2
global class CreateAndModifyScheduler implements Schedulable{
global void execute(SchedulableContext sc) {
CreateAndModify scBatch = new CreateAndModify();
database.executebatch(scBatch);
}
}
// Batch Apex related class 1
global class CreateAndModify implements
Database.Batchable<sObject>, Database.Stateful{
global CreateAndModifyProcessor processor;
global CreateAndModify(){
this.processor = new CreateAndModifyProcessor();
}
global Database.queryLocator start
(Database.BatchableContext BC){
return Database.getQueryLocator([Select Agreement_ID__c, Begining__c,
Contact_Email__c, Contact_Name__c,
Country_Code__c, Currency__c,
Customer_Address__c, Customer_ID__c,
Customer_Name__c,Customer_Postal_Code__c,
Ending__c,Price__c FROM Unprocessed_Agreement__c]);
}
global void execute(
Database.BatchableContext BC,
List<sObject> listObj){
list <Account__c> inAcc = new list<Account__c>();
for (sObject lo : listObj){
Unprocessed_Agreement__c temp = (Unprocessed_Agreement__c)lo;
inAcc.add(processor.processAccountRecord(temp));
}
insert(inAcc);
update(inAcc)
}
global void finish(
Database.BatchableContext BC){
}
}
// Batch Apex related class 2
global class CreateAndModifyProcessor {
global Account__c processAccountRecord( Unprocessed_Agreement__c temp){
Account__c tempAcc = new Account__c();
tempAcc.Customer_Name__c = temp.Customer_Name__c;
tempAcc.Customer_Address__c = temp.Customer_Address__c;
tempAcc.Postal_Code__c = temp.Customer_Postal_Code__c;
return tempAcc;
}
}
Please if someone can have a look at it. Also, if someone wants to see my build.xml or package.xml please tell..Thank You
you’re running a scheduled batch job so every execution is monitored by the system. check setup – administration setup – monitoring – apex jobs for errors.
another debugging option would be using execute anonymous (in eclipse or ui) to execute your job manually and check the logs.