0

Here are the errors I am getting https://prnt.sc/ter539

I have no clue what I am doing wrong as I am following the documentation Salesforce is giving me for Batch Jobs...

Here is my code.

global class ManualShareRemovalBatch implements Database.Batchable<SObject>{
    
    List<Purchase_Order__Share> sharesToDelete = [SELECT Id FROM MyCustomObject__Share WHERE RowCause = 'Manual']
    global Database.QueryLocator start(Database.BatchableContext bc){
            return Database.getQueryLocator([SELECT Id FROM Purchase_Order__Share WHERE RowCause = 'Manual']);
       }  
    
    global void excute(Database.BatchableContext bc, sharesToDelete){
        if(!sharesToDelete.isEmpty()){
                Database.Delete(sharesToDelete, false);
        }
    }
    global void finish(Database.BatchableContext bc){}

} 
1

You missed a semi-colon at the end of line 3.

List<Purchase_Order__Share> sharesToDelete = [SELECT Id FROM MyCustomObject__Share WHERE RowCause = 'Manual'];

You also missed the second parameter's data type from the execute method, and misspelled execute.

    global void execute(Database.BatchableContext bc, Purchase_Order__Share[] sharesToDelete){

That said, line 3 is not necessary and should be removed from the source code.

Also, no need to check if the list is empty (hint: it won't be).

global class ManualShareRemovalBatch implements Database.Batchable<SObject>{
    global Database.QueryLocator start(Database.BatchableContext bc){
            return Database.getQueryLocator([SELECT Id FROM Purchase_Order__Share WHERE RowCause = 'Manual']);
       }  
    
    global void execute(Database.BatchableContext bc, Purchase_Order__Share[] sharesToDelete){
        Database.Delete(sharesToDelete, false);
    }
    global void finish(Database.BatchableContext bc){}

} 
| improve this answer | |
  • Class ManualShareRemovalBatch must implement the method: void Database.Batchable<SObject>.execute(Database.BatchableContext, List<SObject>) is still the error I am getting. This has been like this even when I just have the batch skeleton. I don't know what I am doing wrong, other than the missing semi colon. – Cody Batchelor Jul 9 at 13:42
  • @CodyBatchelor Yes, just noticed you missed the data type of a parameter, too. – sfdcfox Jul 9 at 13:43
  • Where does this change need to be added? – Cody Batchelor Jul 9 at 13:44
  • @CodyBatchelor reload to see my edits. – sfdcfox Jul 9 at 13:45
  • I have made all the changes mentioned above but I am still getting the main error I made this post about, Class ManualShareRemovalBatch must implement the method: void Database.Batchable<SObject>.execute(Database.BatchableContext, List<SObject>) – Cody Batchelor Jul 9 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.