You need to sign in to do that
Don't have an account?

Error: Compile Error: unexpected token: '=' at line 13 column 11
Hi,
I am unable to find what is going wrong....
any help provided is highly appriciated
I am trying to get an attachment from a case and send it through the notification email and have been failing at each attempt.
After Insert triggers in case does not work, it seems to execute even before the records are saved. This is the last thing I am trying now
public with Sharing class notifyEmail { Casetracker__c objectCT; Case objectC; Attachment objectA; User objectU; List<Casetracker__c> listCT = new List<Casetracker__c>(); List<Case> listC = new List<Case>(); List<Attachment> listA = new List<Attachment>(); List<User> listU = new List<User>(); List<EmailTemplate> listET = new List<EmailTemplate>(); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); Messaging.EmailFileAttachment ea = new Messaging.EmailFileAttachment(); listCT = [select Id, Casenumber__c from Casetracker__c where Id = 'a0090000001PMKpAAO']; listC = [select Id, OwnerId from Case where CaseNumber = : listCT.Casenumber__c]; listU = [select Id, Email from User where Id = : listC.OwnerId]; listA = [select Id, Name, Body, ContentType from Attachment where ParentId = : listC.Id]; listET = [select Id, Name, Body, Subject from EmailTemplate where Name = 'Support: Case Assignment Notification']; if(listA.size()> 0) { ea.setFileName(listA.Name); ea.setContentType(listA.ContentType): ea.setBody(listA.Body); ea.setInLine(false); mail.setFileAttachments(new Messaging.EmailFileAttachment[] {ea}); } string[] toadd = new string[] {listU.Email}; mail.setToAddresses(toadd); mail.setReplyTo('spprtemail5@gmail.com'); mail.setSenderDisplayName('SupportEmail'); mail.setSubject(listET.Subject); mail.setHtmlBody(listET.Body); Messaging.sendEmail(new Messagin.SingleEmailMessage[] {mail}); }
Please tell me why I get the above error.
Thanks
KD
Probably because that query won't return a List of objects but just a single instance of your custom Casetracker__c object (due to your where-clause).
When selecting something while having a where-clause like Id = some_id', SF returns just that one object as Id is a unique identifier.
Try re-writing it to this:
Hope this helps.
/Søren Nødskov Hansen
I initially tried it the way you had suggested. I encountered the same error and then went with the list only to see the same error. Is there any kind of a syntax error. If I comment line 13 then the error shows for the next line also.
Thanks
KD
Ok, now I've copy/pasted your code into my IDE and there are several issues.
I haven't looked at optimizing your code/queries or the "logical sanity" of the code - I've simply re-organized it and fixed the compile errors. Here's what I ended up with:
This should bring you forward and hopefully help you reach your goal.
/Søren Nødskov Hansen