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
Cris9931Cris9931 

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 Cris9931
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