+ Start a Discussion
Cristian-Ovidiu TrifCristian-Ovidiu Trif 

Compile Error: Unexpected token ')'. at line 25 column 26


Hi, I have this error on my code:

 

public class Search_For_User
{
    String keyword;

    List<user>results = new List<user>();
    
    public String getkeyword(){
    return keyword;
    }
   
    public List<user> getresults(){
    return results;
    }
    
    public void setkeyword(String input){
    keyword = input;
    }
    
    public PageReference searchUser(){
    results = (List<User>)[FIND :keyword IN NAME FIELDS RETURNING USER(FirstName, LastName, ProfileId)][0];
    return null;
 
    }

     System.debug(results);
 
    
}
Can someone help me please...
Best Answer chosen by Cristian-Ovidiu Trif
Boss CoffeeBoss Coffee
System.debug statements need to be inside of methods of a class. Try moving that System.debug line inside of the methods that assign results its value.

All Answers

Boss CoffeeBoss Coffee
System.debug statements need to be inside of methods of a class. Try moving that System.debug line inside of the methods that assign results its value.
This was selected as the best answer
Sunil RathoreSunil Rathore
Hi Christian,

You need to add System.debug() inside the method. Outside the method it will be treated as a constructor. Try the below code:
public class Search_For_User{
    String keyword;

    List<user>results = new List<user>();
    
    public String getkeyword(){
    return keyword;
    }
   
    public List<user> getresults(){
    return results;
    }
    
    public void setkeyword(String input){
    keyword = input;
    }
    
    public PageReference searchUser(){
    results = (List<User>)[FIND :keyword IN NAME FIELDS RETURNING USER(FirstName, LastName, ProfileId)][0];
     System.debug(results);
    return null;
 
    }
}

Hope this will solve your problem. If does, then mark it as the best answer so it will also help others in the future.

Many Thanks,
Sunil Rathore