You need to sign in to do that
Don't have an account?

Trigger to Update Manager Filed 4 users without Manage Users
I have added a custom lookup field on user object and if users update that field then it update Standard Manger field ( which is not accessible to them without Manage user permission) . And my trigger works great and the problem is when we need to deactivate the user it throws me a error saying the user is a manager for other users. and i need to go and remove them . But in Standard functionlity it doesnt happen that way. And if i try to remove the manager info from custom field then it even remove the info from standard field and i am ultimately losing all the information. Any suggestions please
trigger UserManagerUpdate on User(before insert, before update) {
if (trigger.isInsert || trigger.isUpdate) {
for (User myUser: Trigger.New) {
myUser.ManagerId = myUser.Manager__c;
}
}
}
Thanks
Akhil
trigger UserManagerUpdate on User(before insert, before update) {
if (trigger.isInsert || trigger.isUpdate) {
for (User myUser: Trigger.New) {
myUser.ManagerId = myUser.Manager__c;
}
}
}
Thanks
Akhil
Thanks for the reply
I am getting error System.StringException: Invalid id: : Trigger.UserManagerUpdate: line 4, column 1
All Answers
trigger UserManagerUpdate on User(before insert, before update) {
if (trigger.isInsert || trigger.isUpdate) {
for (User myUser: Trigger.New) {
if(myUser.ManagerID==''){
myUser.ManagerId = myUser.Manager__c;
}
}
}
}
Thanks for the reply
I am getting error System.StringException: Invalid id: : Trigger.UserManagerUpdate: line 4, column 1