• Diego Bacigalupe
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
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);  

}
}