+ Start a Discussion
Shephali SwarnkarShephali Swarnkar 

How to get ID of different users

Hi All,
     I know two ways to get the ID of USER
1.Using query : [select id from user] here we can get all IDs of users.
2.From URL we can the specific user's ID
        here if we want to get user's detail we need supply that ID from UI an way(list, input box etc...) and then we will get the detail.

Question:i need to develop an apex class to let user see their task list and details for which i need user's ID. Is there any other way to get the user's ID without supplying anything from UI so that whenever any user login they can run this apex class and can get their task list detail.
                
Best Answer chosen by Shephali Swarnkar
Ajay K DubediAjay K Dubedi
Hi Shephali Swarnkar,
You can get the current user id like this:-
UserInfo.getUserId()  which returns the user id of the current user.

Thanks.