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
Bob Lee 14Bob Lee 14 

I am getting compilation error at line 25 column 26

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 Bob Lee 14
Deepali KulshresthaDeepali Kulshrestha
Hi Bob,

Greetings to you!

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;
 
    }
}


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com