function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sandesh D GanjareSandesh D Ganjare 

Error: Compile Error: unexpected token: 'return' at line 9 column 8

public class myControllerExtension {
           
    public myControllerExtension(ApexPages.StandardController stdController) {
        //this.acct = (New_Application__c)stdController.getRecord();
        User u = [select FirstName, Lastname from User where Id = :UserInfo.getUserId()];
    }
public String getEmployee_ID() {
        contact c = [select Employee_ID__c from contact where (FirstName = :u.FirstName AND Lastname = :u.Lastname)]
        return 'hello' + c.Employee_ID__c; //here is problem
    }  
    
}
Amit Chaudhary 8Amit Chaudhary 8

Please try below code. ; was missing in query

public class myControllerExtension {
           
    public myControllerExtension(ApexPages.StandardController stdController) {
        //this.acct = (New_Application__c)stdController.getRecord();
        User u = [select FirstName, Lastname from User where Id = :UserInfo.getUserId()];
    }
public String getEmployee_ID() {
        contact c = [select Employee_ID__c from contact where (FirstName = :u.FirstName AND Lastname = :u.Lastname)] ;
        return 'hello' + c.Employee_ID__c; //here is problem
    }  
    
}

Please let us know if this will help u
Arunkumar RArunkumar R
Hi Sandesh,

     Please try the bleow one. Use UserInfo class to avoid one query in your constructor.
 
public class myControllerExtension {
           
    public myControllerExtension(ApexPages.StandardController stdController)
    {
        //this.acct = (New_Application__c)stdController.getRecord();
    }
    public String getEmployee_ID()
    {
        contact c = [select id, Employee_ID__c from contact where (FirstName = :Userinfo.getFirstName() AND Lastname = :Userinfo.getLastName())] ;
        return 'hello' + c.Employee_ID__c; //here is problem
    }  
    
}

Thanks.