You need to sign in to do that
Don't have an account?
dwright01
Can Apex code tell if an administrator logged in as another user?
Does anyone know a way for my Apex code to determine the difference in being logged in as a standard Salesforce user, versus an Admin user that logged in and in their admin session logged in as that user?
Thanks,
David Wright, Gerson Lehrman Group
Hi,
1. Get logedIn UserId help of Id userId = UserInfo.getUserid();
2. get the User record with help of user id
User logedInUser = [Select u.Profile.Name, u.Profile.Id, u.ProfileId From User u where id=:userId];
3. check the profile name help of
if(logedInUser.Profile.Name=='standard Salesforce')
{
// write code
}
else if(logedInUser.Profile.Name=='System Administrator')
{
//write code here
}
If not, did you figure out a way to do what you were looking for?