i am facing this problem too.i have create a rest service that will check the lead and contact in salesforce if lead or contact is exists then send rest response along with object type.Please suggest me how to do this??? when i use gettype() method then following error comes "Error: Compile Error: Variable does not exist: Company at line 37 column 43"



global class SQUser

 global static String CheckLead()    
   String EmailID = RestContext.request.params.get('Email_id');    

   LIST<Lead> ledID = [Select ID from Lead where Email=:EmailID LIMIT 1];     
   LIST<Contact> conID= [Select ID from Contact where Email=:EmailID LIMIT 1];

    return ledID[0].ID;    
   else if(conID.size()>0)    
     return 'ContactID '+ conID[0].ID;    
    return 'No record found either for Lead or contact.';    

 global static String CreateRecord()    
    Lead ledID = new Lead();    
    ledID.FirstName = RestContext.request.params.get('Fist_nm');    
    ledID.LastName = RestContext.request.params.get('Last_nm');    
    ledID.Phone = RestContext.request.params.get('Phone');    
    ledID.Email = RestContext.request.params.get('Email');    
    ledID.Company= RestContext.request.params.get('Company');

    insert ledID;

    Schema.DisplayType myType = ledID.get(Company).getDescribe().getType();    
    return 'Newly Lead Created ' +ledID.ID;    
  • This isn't really an answer. It would be better to post this as a question. – Jagular Aug 6 '14 at 14:01

You're trying to reference a symbol (company) that doesn't exist.

If you need dynamic code:


Where objectName and fieldName are strings, such as 'Lead' and 'Company'.

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.