+ Start a Discussion
learn_sfdclearn_sfdc 

First error: line 1:90 no viable alternative at character '<EOF>'

Hello,
I have got - First error: line 1:90 no viable alternative at character '<EOF>'

Below is the code where the error referenced


global class batchCaseAttachmentDeletionClass implements Database.Batchable<SObject>  
{
    global String CaseQuery;
    global Date custom_closed_date;
   
    
    
    global batchCaseAttachmentDeletionClass()
     {
CaseQuery = 'Select Id,custom_closed_date__c from Case where custom_closed_date__c= '+ Date.Today().AddDays(-8);
     }
     
global Database.QueryLocator start(Database.BatchableContext bcMain) {
  return Database.getQueryLocator(CaseQuery);
}

         global void finish(Database.BatchableContext bFinish)
{

}
    


// "Execute" is what is being run as a separate process per batch
global void execute(Database.BatchableContext bcMain, List<SObject> lstBatchRecords) 
{
    Set<Id> caseId = new set<Id>();
    List<Case> cs_List = (List<Case>)lstBatchRecords;
    List<CaseComment> lst_CaseComment = new List<CaseComment>();
    
    for(Case cs : cs_List)
     {
        caseId.add(cs.id);
     }
     
  List<Attachment> listAttachment = new List<attachment>([Select Id,ParentId,Name,Body from Attachment where ParentId IN:
                                                          caseId]);
                                                          
    
   for(Attachment attachmentRecd : listAttachment) 
    {
      CaseComment cseComment = new CaseComment();
      cseComment.ParentId = attachmentRecd.ParentId;
      cseComment.CommentBody = 'Attachment -'+ attachmentRecd.Name +  'has been deleted';
      lst_CaseComment.add(cseComment);
    }
    

    
    if(listAttachment!=null && listAttachment.size()>0)
     {
        try
         {
        delete listAttachment;
        insert lst_CaseComment;
         }catch(Exception e)
           {
             throw e;
           }
     }
     
     }
     
     }
v varaprasadv varaprasad
Hi ,

Please remove following line once : implements Database.Batchable<SObject> {
Please type above line again dont paste the code.because of spaces between Database.Batchable<SObject>  and { error thrown.

Hope this helps.
If this is the correct answer please mark it as best answer.

Thanks
Varaprasad
 
learn_sfdclearn_sfdc
Hi Varaprasad,

Its still the same error:

First error: line 1:90 no viable alternative at character '<EOF>'
v varaprasadv varaprasad
please delete your class and add below class:
 
global class batchCaseAttachmentDeletionClass implements Database.Batchable<SObject>{
    global String CaseQuery;
    global Date custom_closed_date;
    
    
    
    global batchCaseAttachmentDeletionClass()
    {
        CaseQuery = 'Select Id,custom_closed_date__c from Case where custom_closed_date__c= '+ Date.Today().AddDays(-8);
    }
    
    global Database.QueryLocator start(Database.BatchableContext bcMain) {
        return Database.getQueryLocator(CaseQuery);
    }
    
    global void finish(Database.BatchableContext bFinish)
    {
        
    }
    
    
    
    // "Execute" is what is being run as a separate process per batch
    global void execute(Database.BatchableContext bcMain, List<SObject> lstBatchRecords) 
    {
        Set<Id> caseId = new set<Id>();
        List<Case> cs_List = (List<Case>)lstBatchRecords;
        List<CaseComment> lst_CaseComment = new List<CaseComment>();
        
        for(Case cs : cs_List)
        {
            caseId.add(cs.id);
        }
        
        List<Attachment> listAttachment = new List<attachment>([Select Id,ParentId,Name,Body from Attachment where ParentId IN:
                                                                caseId]);
        
        
        for(Attachment attachmentRecd : listAttachment) 
        {
            CaseComment cseComment = new CaseComment();
            cseComment.ParentId = attachmentRecd.ParentId;
            cseComment.CommentBody = 'Attachment -'+ attachmentRecd.Name +  'has been deleted';
            lst_CaseComment.add(cseComment);
        }
        
        
        
        if(listAttachment!=null && listAttachment.size()>0)
        {
            try
            {
                delete listAttachment;
                insert lst_CaseComment;
            }catch(Exception e)
            {
                throw e;
            }
        }
        
    }
    
}

Thanks
Varaprasad​