+ Start a Discussion

User Deletion

Dear All,


I want to delete the user (means inactivate him) based on some criteria.For that i will schedule a class which runs daily and if my criteria is met i will delete the user.


Now the problem is if the user  whom i am going to delete a manager for some set of users how to handle those user deletions since i am getting exception <Cannot inactivate user that is the value of a hierarchy field: Account Request Approver.>


Please help out...

Amritesh SinghAmritesh Singh



I think before deleting user you have to check the hierarchy, If that user have subordinates then 1st of all you have to assign new User(Manager) of those subordinates and then delete that user.




Do you have any field Account Request Approver in User ?

Yes... Account request approver is the field created by us...

Ok So the problem is the User which you are marking as inactive is assingned to "Account Request Approver" of some other user.

What you have to do is Select all the user where Account Request Approver = <User You are marking inactive> and assign so other value to it .

After doing this you can mark the original User Inactive.
So steps will be
1. Check if the user you are marking inactive is selected in Account Request Approver of some other user.
2.If yes change them to some other value
3.Save the Users where Account Request Approver = User you are marking inactive
4.Mark the user inactive
This also will error if a custom user field has been deleted, but not yet been erased form the system. That drove me nuts for a bit...