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

Code help

I have a string named FAM and a list of users as shown below



List <user> use = [select name,EmployeeNumber from User];


string FAM = '0001';




I want to check if the Employeenumber in the list named use contains this FAM value.
How to do i check? Pls help



         String FAM = '0001';

         List <user> use = [select name,EmployeeNumber from User where EmployeeNumber =:FAM];

         String ename = use[0].Name;

       try this one.........




You can put filter on query itself and it will return you desired result set in list. Code snippet may look something like below:-


string FAM = '0001';

String query = 'select name,EmployeeNumber from User where EmployeeNumber like '%' + FAM + '%';

List <user> use = Database.query(query);


Let me know if you have any question about above.


Happy to help you!