I have two Apex classes that differ by literally only their name. Here's MaintenanceRequestBatch.cls
:
public with sharing class MaintenanceRequestHelper implements Database.Batchable<sObject>{
public List<Id> ids;
public MaintenanceRequestHelper(List<Id> ids) {
this.ids = ids;
}
public Database.QueryLocator start(Database.BatchableContext context) {
return Database.getQueryLocator('SELECT Id FROM Case WHERE ID in :this.ids');
}
public void execute(Database.BatchableContext context, List<Case> cases) {}
public void finish(Database.BatchableContext context) {}
}
Here's Batch.cls
:
public with sharing class Batch implements Database.Batchable<sObject>{
public List<Id> ids;
public Batch(List<Id> ids) {
this.ids = ids;
}
public Database.QueryLocator start(Database.BatchableContext context) {
return Database.getQueryLocator('SELECT Id FROM Case WHERE ID in :this.ids');
}
public void execute(Database.BatchableContext context, List<Case> cases) {}
public void finish(Database.BatchableContext context) {}
}
Here's the diff
on those two files:
1c1
< public with sharing class Batch implements Database.Batchable<sObject>{
---
> public with sharing class MaintenanceRequestHelper implements Database.Batchable<sObject>{
4c4
< public Batch(List<Id> ids) {
---
> public MaintenanceRequestHelper(List<Id> ids) {
Now I have a third class, MaintenanceRequestHelper
that's supposed batchify an operation. Here's what it looks like first.
public with sharing class MaintenanceRequestHelper {
public static void updateWorkOrders(List<Case> cases) {
List<id> ids = new List<Id>();
for (Case oneCase : cases) {
ids.add(oneCase.Id);
}
Batch b = new MaintenanceRequestBatch(ids);
}
}
If I try to deploy this, I get the following error:
SOURCE PROGRESS | █████████████████████████████████████░░░ | 11/12 Components
TYPE PROJECT PATH PROBLEM
───── ─────────────────────────────────────────────────────────── ────────────────────────────────────────────
Error force-app/main/default/classes/MaintenanceRequestHelper.cls Invalid type: MaintenanceRequestBatch (7:19)
ERROR running force:source:deploy: Deploy failed.
But if I change the word MaintenanceRequestBatch
in line 7 above, I get no error.
Batch b = new Batch(ids);
I think I must be missing something obvious. I've been copying and pasting to make sure everything is exactly the same except for the class name and therefore constructor name. How can changing that one thing give me an invalid type?