I have a queueable apex that calls to a batch.

Inside the queueable class - I have inner Class that writes a log with incorrect fields.

The Inner Class inside the queueable class :

public class ErrorClassToSend{
        Date todayDate;
        String name;
        String email;

        List<String> contactErrorFeidls;
        List<String> grantErrorFeidls;
        List<String> coursesErrorFeidls;

        public ErrorClassToSend(){
            this.contactErrorFeidls = new List<String>();
            this.grantErrorFeidls = new List<String>();
            this.coursesErrorFeidls = new List<String>();
            this.todayDate = Date.today();



Then I'm creating a Map when the email is the key.

 Map<String,ErrorClassToSend> errorMapCls = new Map<String,ErrorClassToSend>();

After filling the Map I calling the Batch with another param - Map of contacts named contactMap :

StudentFileBatch bStud = new StudentFileBatch(contactMap,errorMapCls);

Id batchJobId = Database.executeBatch(bStud, 200);

In my Batch :

I created the same inner class also in the batch (ErrorClassToSend), and I created a variables to store the income params from the queueable class :

Map<String,String> contactMap = new Map<String,String> ();
Map<String,ErrorClassToSend> errorMap = new Map<String,ErrorClassToSend>();

and then inside the Batch constructor :

public StudentFileBatch(Map<String,String> contactMap ,Map<String,ErrorClassToSend> errorMap) {

I'm getting the Error when compliled :

Constructor not defined: [StudentFileBatch].<Constructor>(Map<String,String>, Map<String,StudentFileQuable.ErrorClassToSend>)

I tried to send Map to the batch and getting it with the same way, but same error.

Any help?


One class is not the same as another, even if it has the same name. However, you can modify your batch to simply use the first's:

Map<String,StudentFileQuable.ErrorClassToSend> errorMap = new Map<String,StudentFileQuable.ErrorClassToSend>();

Alternatively, you could pull out the class into its own top-level class, since it's to be shared between the two.

The constructor would be likewise modified in your batch class:

public StudentFileBatch(Map<String,String> contactMap ,Map<String,StudentFileQueble.ErrorClassToSend> errorMap) {

You could also avoid a bit of overhead by assigning the map directly:

public StudentFileBatch(Map<String,String> contactMap ,Map<String,StudentFileQueble.ErrorClassToSend> errorMap) {
    this.errorMap = errorMap;
| improve this answer | |
  • 2
    Indeed, these classes don't have the same name since their (fully qualified) name includes the outer class (and namespace where that is applicable). Only the local name looks the same. – Phil W Jan 7 at 17:42
  • Thanks. I actually thought it gonna work when I defined the same inner class inside both of the classes. Thank you – Salvation Jan 8 at 8:01

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.