+ Start a Discussion
Nikhil SomvanshiNikhil Somvanshi 

Error: Compile Error: Class DisasterRapMonitor must implement the method: void Database.Batchable<SObject>.execute(Database.BatchableContext, List<SObject>) at line 1 column 14

Hello Masters,

I am writing the following Batch but not able to save it. It only ends up with the afore-stated error even though I have included the execute method perfectly to my knowledge. I am mentioning my Class code below and would appreciate any help.

Class:
Global class DisasterRapMonitor implements Database.Batchable <sObject>
{

Global Database.QueryLocator start (Database.BatchableContext BC)
{
String DisasterWithoutRap = 'Select id,name from Disaster__c where id NOT in (select DisasterId from Response_Action_Plan__c)';
return Database.getQueryLocator(DisasterWithoutRap);
}

Global void execute ( Database.BatchableContext BC,List<Disaster__c> Dis)
{
for (Disaster__c di:Dis)
    {
    Task tk = new Task ();
    tk.Subject = 'Need to be associated with a Response immediately. Please work it out.';
    tk.WhoId = di.Id;
    }
    
    Update Dis;
}

Global void finish (Database.BatchableContext BC)
{}

}

Best Answer chosen by Nikhil Somvanshi
Manj_SFDCManj_SFDC
Hi check if you have created the Disaster__c object and if yes try to check you are using the name correctly, rest all looks good, please mark this as solved if this helps you
Good Luck !

All Answers

v varaprasadv varaprasad
Hi Nikhil,

Please let me know your requirement so that I can help you.
 
Global void execute ( Database.BatchableContext BC,List<Disaster__c> Dis)
{
	
	list<task> lstTaks = new list<task>();
	
for (Disaster__c di:Dis)
    {
    Task tk = new Task ();
    tk.Subject = 'Need to be associated with a Response immediately. Please work it out.';
    tk.WhoId = di.Id;
	lstTaks.add(tk);
    }
    insert lstTaks;
    //Update Dis; Here why are you updating list it is not needed you are not updating any records.
}



Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.

Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com



 
Waqar Hussain SFWaqar Hussain SF
Try below code
 
Global class DisasterRapMonitor implements Database.Batchable <Disaster__c>
{

Global Database.QueryLocator start (Database.BatchableContext BC)
{
String DisasterWithoutRap = 'Select id,name from Disaster__c where id NOT in (select DisasterId__c from Response_Action_Plan__c)';
return Database.getQueryLocator(DisasterWithoutRap);
}

Global void execute ( Database.BatchableContext BC,List<Disaster__c> Dis)
{
for (Disaster__c di:Dis)
    {
    Task tk = new Task ();
    tk.Subject = 'Need to be associated with a Response immediately. Please work it out.';
    tk.WhoId = di.Id;
    }
    
    Update Dis;
}

Global void finish (Database.BatchableContext BC)
{}

}

 
Manj_SFDCManj_SFDC
Hi check if you have created the Disaster__c object and if yes try to check you are using the name correctly, rest all looks good, please mark this as solved if this helps you
Good Luck !
This was selected as the best answer
Nikhil SomvanshiNikhil Somvanshi
Thank you everyone for your concernful replies, but manj's point helped me save the program, as the API name was incorrect.