I am getting this error "unexpected token: 'name'" from this piece in my trigger. Why?

trigger trgr_Related_Staff_Position on Related_Staff_Positions__c (after insert,after update,after delete) 

    List<ConRelated_Staff_Positions__ctact> rsp_List = new List<Related_Staff_Positions__c>();
    rsp_LIst = [Select Contact__c , first name, last name from Related_Staff_Positions__c where Contact__c IN: Trigger.New];
  • First name and last name are custom fields isn't it? – highfive Jun 27 '16 at 8:30
  • Yes. I forgot the proper syntax. Please me this an answer and I'll mark it as such. – Apex N-u-b Jun 27 '16 at 8:34

You are having spaces between words. Try using below

rsp_LIst = [Select Contact__c , firstname__c, lastname__c from Related_Staff_Positions__c where Contact__c IN: Trigger.New];

Still this depends on your correct API name of the field. It may be first_name__c and last_name__c. Check the field API name from the object view if it's not sure.

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.