+ Start a Discussion
carmilyn.c martincarmilyn.c martin 

First error: Invalid id:

We have a scheduled job that runs every 6am but we received this error: "First error: Invalid id:"

Apex Class: Eisai_HCPMail_Batchable_Cls

global class Eisai_HCPMail_Batchable_Cls implements Database.Batchable<sObject>
{
    global final String Query;
    global Eisai_HCPMail_Batchable_Cls(String q)
    {
        Query=q;   
    }             
    global Database.QueryLocator start(Database.BatchableContext BC)
    {
        System.Debug('#######Start method called');
        return Database.getQueryLocator(query);
   }
   global void execute(Database.BatchableContext BC,List<sObject> scope)
   {
        System.Debug('#######executeCalled');
        System.Debug('#######callsamplesList'+scope);
        Eisai_TaskHelper_Cls obj = new Eisai_TaskHelper_Cls (); 
        //obj.SendmailtoHCP_forBatch(scope);
        obj.sendHcpCntatdBatchMail(scope);
   }//end of execute
   global void finish(Database.BatchableContext BC)
   {

   }

}//end of batch class


Another Apex Class: 

global Class Eisai_HCPMail_Schedule_Cls implements Schedulable {
public String query; 
global void execute(SchedulableContext sc)
{
 System.Debug('@@@@@@SchedulerCalled');


      query='Select '+
            'Assigned_To_esi__c,Task_Owner_Profile__c,Assign_To_Med_Comm_esi__c,Assign_User_Email__c,HCP_Contacted_Date_esi__c,  '+
            'HCP_Contacted_esi__c,HCP_Contacted_text__c,OwnerId,No_of_Reminder_eMails_esi__c,whoId,Number_of_Days_to_Contact_esi__c '+ 
            'from Task '+
            'WHERE HCP_Contacted_esi__c =false '+
            'and Is_HCP_enable_esi__c =true '+
            'and Number_of_Days_to_Contact_value__c > 3 '+
            'and No_of_Reminder_eMails_esi__c < 3 '+
      //      'and OwnerId=\'005A0000002KfY1\''+
          ' and Status !=\'Completed\''+
            ' and Request_Type_esi__c =\'MSL Request\'';

Id batchInstanceId = Database.executeBatch(new Eisai_HCPMail_Batchable_Cls(query),5);  

}
}
Vishal_GuptaVishal_Gupta
Hi Martin,

Can you also share your Eisai_TaskHelper_Cls code. Also let me know how many batches are failing means all or some are failing and rest are executing successfully.

Thanks,
Vishal
 
carmilyn.c martincarmilyn.c martin
Total Batches: 5 Batch Process: 5 Failures: 4

The Scheduled job has a Completed Status 

Can i send it via email?
 
Vishal_GuptaVishal_Gupta
Hi Martin,

Yes please share your code on my email id :  vishal.er.gupta@gmail.com

Thanks,
Vishal
Diego BacigalupeDiego Bacigalupe
Hi Martin, Vishal,
can you please provide some feedback about this error. I am also facing the same issue. There is a scheduled job running. If I check the AsyncApexJob table, I see the following: 
ExtendedStatus: First error: Invalid id:
JobItemsProcessed: 423
TotalJobItems: 423
JobType: Batch Apex
NumberOfErrors: 2
Status: Completed
Why can be the cause of this error?
Thanks!
Diego