You need to sign in to do that
Don't have an account?
SF7
Hi ,
My Batch class is not saving and giving m ethe follow errors need help please
Error1: Compile Error: S2S_PropogateParent: Class must implement the global interface method: Iterable<SObject> start(Database.BatchableContext) from Database.Batchable<SObject>,
Error 2 :S2S_PropogateParent: Class must implement the global interface method: void execute(Database.BatchableContext, LIST<SObject>) from Database.Batchable<SObject>,
Error 3 : S2S_PropogateParent: Class must implement the global interface method: void finish(Database.BatchableContext) from Database.Batchable<SObject> at line 1 column 14
global class S2S_PropogateParent implements Database.Batchable<sObject> {
global void execute(SchedulableContext SC) {
S2S_Utils su = new S2S_Utils();
// clear out previously completed records
Datetime hourAgo = DateTime.now().addHours(-1);
List<S2SParentPropogation__c> deleteNow = [SELECT Id FROM S2SParentPropogation__c WHERE Status__c = 'Completed' AND CreatedDate < :hourAgo];
try {
delete deleteNow;
} catch (Exception e) {
// meh, it was probably already deleted by another job running in parallel
}
/****************** Retrieve Data **********************/
// what records are out there awaiting sync
Datetime minsAgo = DateTime.now().addMinutes(-1);
List<S2SParentPropogation__c> processNow =
[SELECT LocalId__c, LocalAccountId__c, Status__c
FROM S2SParentPropogation__c
WHERE Status__c = 'Inserted'
AND (JobID__c = 'DOH-testing' OR CreatedDate < :minsAgo)];
// get list of accounts so we know which sync records to look for
List<ID> localAccountIds = new List<ID>();
for (S2SParentPropogation__c pp : processNow) {
localAccountIds.add(pp.LocalAccountId__c);
}
// which of those accounts have completed sync?
List<PartnerNetworkRecordConnection> findSynchedAccounts = su.findAlreadySynchedAccounts(localAccountIds);
/****************** Add Sync Records **********************/
List<PartnerNetworkRecordConnection> newSynchRecords = new List<PartnerNetworkRecordConnection>();
for (S2SParentPropogation__c p : processNow) {
// find corresponding account S2S sync record
PartnerNetworkRecordConnection accountS2S = null;
for (PartnerNetworkRecordConnection pn : findSynchedAccounts) {
if (pn.LocalRecordId == p.localAccountId__c) {
accountS2S = pn;
}
}
// found it
if (accountS2S != null) {
// auto-share this contact/opportunity with the client org
newSynchRecords.add(su.buildPartnerConnectionRecord(p.LocalId__c, p.LocalAccountId__c));
p.Status__c = 'Completed';
}
}
insert newSynchRecords;
update processNow;
}
}
-------------------------------------------------------------
If i replace the first line with global class S2S_PropogateParent implements Schedulable { but if i use this i cannot schedule the batch class as it throws me an error Argument must be an object that implements Database.Batchable
Thanks
Akhil
Batch Class errors
Hi ,
My Batch class is not saving and giving m ethe follow errors need help please
Error1: Compile Error: S2S_PropogateParent: Class must implement the global interface method: Iterable<SObject> start(Database.BatchableContext) from Database.Batchable<SObject>,
Error 2 :S2S_PropogateParent: Class must implement the global interface method: void execute(Database.BatchableContext, LIST<SObject>) from Database.Batchable<SObject>,
Error 3 : S2S_PropogateParent: Class must implement the global interface method: void finish(Database.BatchableContext) from Database.Batchable<SObject> at line 1 column 14
global class S2S_PropogateParent implements Database.Batchable<sObject> {
global void execute(SchedulableContext SC) {
S2S_Utils su = new S2S_Utils();
// clear out previously completed records
Datetime hourAgo = DateTime.now().addHours(-1);
List<S2SParentPropogation__c> deleteNow = [SELECT Id FROM S2SParentPropogation__c WHERE Status__c = 'Completed' AND CreatedDate < :hourAgo];
try {
delete deleteNow;
} catch (Exception e) {
// meh, it was probably already deleted by another job running in parallel
}
/****************** Retrieve Data **********************/
// what records are out there awaiting sync
Datetime minsAgo = DateTime.now().addMinutes(-1);
List<S2SParentPropogation__c> processNow =
[SELECT LocalId__c, LocalAccountId__c, Status__c
FROM S2SParentPropogation__c
WHERE Status__c = 'Inserted'
AND (JobID__c = 'DOH-testing' OR CreatedDate < :minsAgo)];
// get list of accounts so we know which sync records to look for
List<ID> localAccountIds = new List<ID>();
for (S2SParentPropogation__c pp : processNow) {
localAccountIds.add(pp.LocalAccountId__c);
}
// which of those accounts have completed sync?
List<PartnerNetworkRecordConnection> findSynchedAccounts = su.findAlreadySynchedAccounts(localAccountIds);
/****************** Add Sync Records **********************/
List<PartnerNetworkRecordConnection> newSynchRecords = new List<PartnerNetworkRecordConnection>();
for (S2SParentPropogation__c p : processNow) {
// find corresponding account S2S sync record
PartnerNetworkRecordConnection accountS2S = null;
for (PartnerNetworkRecordConnection pn : findSynchedAccounts) {
if (pn.LocalRecordId == p.localAccountId__c) {
accountS2S = pn;
}
}
// found it
if (accountS2S != null) {
// auto-share this contact/opportunity with the client org
newSynchRecords.add(su.buildPartnerConnectionRecord(p.LocalId__c, p.LocalAccountId__c));
p.Status__c = 'Completed';
}
}
insert newSynchRecords;
update processNow;
}
}
-------------------------------------------------------------
If i replace the first line with global class S2S_PropogateParent implements Schedulable { but if i use this i cannot schedule the batch class as it throws me an error Argument must be an object that implements Database.Batchable
Thanks
Akhil
where is you have implemented
global Database.QueryLocator start(Database.BatchableContext BC)
{
}
and
global void finish(Database.BatchableContext BC)
{
}
i belive you have to implement all 3 method
start , execute and finish
Database.Schedulable <sObject>
global class S2S_PropogateParent implements Schedulable {
global void execute(SchedulableContext ctx)
{
your code
}
}
1.Class MyfirstbatchApex must implement the method: void Database.Batchable<SObject>.execute(Database.BatchableContext, List<SObject>)
2. global methods do not support parameter type of List<Account>
global class MyfirstbatchApex implements Database.Batchable<sObject>{
global String [] email = new String[] {'kumaranil.java@gmail.com'};
global Database.Querylocator start(Database.BatchableContext bc ){
return Database.getQueryLocator('Select id, Name, AccountNumber, site,AnnualRevenue,NumberOfEmployees From Account');
}
global void execute(Database.BatchableContext bc,List<Account> scope){
List<Account> acclst=new List<Account>();
for(Account a:scope){
a.AccountNumber='11111111';
a.Site='www.zensar.com';
a.AnnualRevenue=567700;
a.NumberOfEmployees=890;
acclst.add(a) ;
}
update acclst;
}
global void finish(Database.BatchableContext bc){
AsyncApexJob a = [Select a.TotalJobItems, a.Status, a.NumberOfErrors, a.JobType, a.JobItemsProcessed, a.ExtendedStatus, a.CreatedById, a.CompletedDate From AsyncApexJob a WHERE id = :BC.getJobId()];//get the job Id
System.debug('$$$ Jobid is'+BC.getJobId());
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(email);
mail.setReplyTo('anil007.tiwari@gmail.com');
mail.setSenderDisplayName('Apex Batch Processing Module');
mail.setSubject('Batch Processing '+a.Status);
mail.setPlainTextBody('The Batch Apex job processed '+a.TotalJobItems+'batches with '+a.NumberOfErrors+'failures'+'Job Item processed are'+a.JobItemsProcessed);
Messaging.sendEmail(new Messaging.Singleemailmessage [] {mail});
}
}