0

Note: I am new to SF and Apex, and still learning appropriate terminology.

We have a global class (Class_A) that says it "implements Database.Batchable." We've learned that the code can be replaced with formula fields, and would like to delete the class.

There exists Class_B which appears to update a single field on the Accounts and then has the following method:

global void finish(Database.BatchableContext BC) {
    Database.executeBatch(new Class_A(), 10);
}

I cannot delete Class_A from production because of the dependency in Class_B. I cannot comment out the method from Class_B because there is a Problem: "Class_B must implement the method: void Database.Batchable.finish(Database.BatchableContext)."

I've decided, I could probably find a way to Flow what's needed for the field update, and then delete Class_B. But, guess what! Class_B is later called in Class_C which is also implements Database.Batchable, and also only has Class_B as its 'finish'. So I cannot delete Class_B until I change Class_C.

Class_C seems to update a number of other things, and this is truly just bringing me down a rabbit hole while I'm trying to fix another problem altogether. A colleague suggested creating a "DoNothingClass" which can temporarily replace the 'finish executiveBatch.' This would allow me to change Class_B, delete Class_A, complete my current project, and then I can get started on the adjustments for Class_B and Class_C.

As I mentioned, I am new to Apex and such, and the appropriate syntax for Batch classes is quite foreign to me. Could someone please assist in the writing of such a class? Could I just comment out the entire class and let it run a blank file?

0

1 Answer 1

0

You don't need to comment out the entire class or method, just comment out that line of code:

// Database.executeBatch(new Class_A(), 10);

Or remove it entirely. There's no rule that says you must have code inside a method, it's just by convention that we normally do want our methods to do something.

2
  • When I comment out just that line of code I get the Error "Class_B must implement the method: void Database.Batchable.finish(Database.BatchableContext)." and it won't let me save the file.
    – user123801
    Oct 26, 2022 at 21:34
  • Oh! I was deleting the whole section, not just the line. Thanks so much!
    – user123801
    Oct 26, 2022 at 21:37

You must log in to answer this question.