You need to sign in to do that
Don't have an account?
fiona gentry
Anonymous apex to update Profile Name
Dear Folks,
Written a anonymous apex to update the user's profile name from Profile1 to Profile 2,i see anonymous apex ran successfully ,but i dont see the Profile.name got changed,any idea what is going wrong with below code
Your help is appreciated
Regards
Fiona
Written a anonymous apex to update the user's profile name from Profile1 to Profile 2,i see anonymous apex ran successfully ,but i dont see the Profile.name got changed,any idea what is going wrong with below code
List<User> lstUsers = new List<User>(); for(User userToChangePermission : [SELECT ID,firstname,lastname,username,isActive,Profile.Name FROM User WHERE Profile.Name = 'Profile1' LIMIT 100 ]) {userToChangePermission.Profile.Name = 'Profile2'; lstUsers.Add(userToChangePermission);} if(!lstUsers.isEmpty()) { System.debug(lstUsers); Update lstUsers; }
Your help is appreciated
Regards
Fiona
try with below code. You need to assign profile Id instead of Name.
If this helps, Please mark it as best answer.
Thanks!!
All Answers
try with below code. You need to assign profile Id instead of Name.
If this helps, Please mark it as best answer.
Thanks!!