function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ashish PathaniaAshish Pathania 

getting INACTIVE_OWNER_OR_USER while unit testing for deactivating user.

 writing the unit test for deactivate user method,in the code after giving the run.As  for the current user, i gave it for the user I am deleting. So it is giving the error of INACTIVE_OWNER_OR_USER,  pls guide
Best Answer chosen by Ashish Pathania
Jessica RiffeJessica Riffe
You cannot delete users, only deactivate or freeze.  Deactivated users cannot update records.

There IS a setting that allows you to update a record that is owned by an inactive user.
If you got to Setup -> User Interfact
Under the Setup section there is a checkbox for: Enable "Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners" User Permissions.
NOTE:  Once you enable this preference, enable one or both of the user permissions in a permission set or profile.

All Answers

Jessica RiffeJessica Riffe
You cannot delete users, only deactivate or freeze.  Deactivated users cannot update records.

There IS a setting that allows you to update a record that is owned by an inactive user.
If you got to Setup -> User Interfact
Under the Setup section there is a checkbox for: Enable "Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners" User Permissions.
NOTE:  Once you enable this preference, enable one or both of the user permissions in a permission set or profile.
This was selected as the best answer
Ajay K DubediAjay K Dubedi
Hi Ashish,

* You cannot delete users from Salesforce. You can remove their license or deactivate them to remove access to the system, but because they may still own records, they cannot be deleted.
  
* Refer through below link why you can not delete a user:

   https://help.salesforce.com/articleView?id=deactivating_users.htm&type=5 (https://help.salesforce.com/articleView?id=deactivating_users.htm&type=5)
 
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com