You need to sign in to do that
Don't have an account?
kfm2012
Get Logged in User Id from with Apex Trigger
I have the following test Apex trigger on the Case Object.
trigger setCaseOwner on Case (before Insert)
{
Case x = trigger.new[0];
x.Description = 'TRIGGER FIRED' + User.Id ;
}
I'm trying to get the ID or Alias of the logged in user. The script below displays TRIGGER FIREDId in the description field of the Case after saving. I've also tried 'TRIGGER FIRED' + $User.Id and 'TRIGGER FIRED' + x.$User.Id which gives me syntax errors. what's the easiest way to get information about the logged in user from within an Apex Trigger?
thx
string uid = userinfo.getUserId();
All Answers
string uid = userinfo.getUserId();
thx!