+ Start a Discussion
Gary WGary W 

Error "INACTIVE_OWNER_OR_USER, Record owner cannot be an inactive user", being thrown even when "Update Records with Inactive Owners" is enabled

The error "INACTIVE_OWNER_OR_USER, Record owner cannot be an inactive user" is being thrown in my flow, when it tries to create a new opportunity using an inactive users ID as the ownerId, via an apex action.

The desired outcome is to allow the inactive user to become the owner of the opportunity record. I followed the below article to enable setting "Update Records with Inactive Owners".

With this setting enabled, I created a permission set and included "Update Records with Inactive Owners" in it, then assigned it to my user. I am now able to manually insert an opportunity with the ownerId set to an inactive user, without error.

In my flow, I'm using a custom apex action to convert a lead to an account/contact/opportunity. When debugging the flow and using the inactive user, it fails with the error "INACTIVE_OWNER_OR_USER, Record owner cannot be an inactive user".

I don't understand why I'm able to insert an opportunity with an inactive user as the opportunity owner manually, but not though an apex action.
ShirishaShirisha (Salesforce Developers) 
Hi Gary,


Please be informed that "In Salesforce, all apex code run in system mode. It ignores user’s permissions. Only exception is anonymous blocks like developer console and standard controllers. Even runAs() method doesn’t enforce user permissions or field-level permissions, it only enforces record sharing."

Please refer the article (https://www.sfdcpoint.com/salesforce/system-mode-and-user-mode-in-salesforce/#:~:text=In%20Salesforce%2C%20all%20apex%20code,it%20only%20enforces%20record%20sharing.) for the same information.

Also,please refer which automated process runs in which mode (user/System Mode).


Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri
Gary WGary W
Hi Shirisha,

Thanks for this information. I wasn't aware of that.

In that case, is it at all possible for apex to create an opportunity owned by an inactive user?
Griffin HomanGriffin Homan

Is this something you were ever able to sort out? I'm running into the same issue, and wondering if there is a work-around.

Gary WGary W
Hi Griffin,

I had to do this in 2 steps. I ended up using the flow running users ID to create the opportunity, then used an update records element to later set the owner to the inactive user.