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
hamza akouayrihamza akouayri 

Can we use userInfo.getUserId() in Apex InvocableMethod to get running userId ?

there is any we can use userInfo.getUserId() in Apex InvocableMethod to get the actually running userId instead of automated process id?
Suraj Tripathi 47Suraj Tripathi 47
Hi Hamza,

Yes, you can userInfo.getUserId() in Apex InvocableMethod to get running userId.
you can get id or firstName or etc which you want from this line of code :

User usrObj = [select firstname from user where id=:userinfo.getuserid()];
string username = usrObj.firstname;
string userId = usrObj.id;
Or 
string userId = userinfo.getuserid();

---------------
If you find your Solution then mark this as the best answer to close this question. 

Thank you!
Regards,
Suraj Tripathi