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
Geek62Geek62 

INACTIVE_OWNER_OR_USER, operation performed with inactive user: []",

Error: Failure Message: "System.DmlException: Insert failed. First exception on row 407; first error: INACTIVE_OWNER_OR_USER, operation performed with inactive user: []", 

 

Hi all,

 

We have a really weird situation. Sounds like this may be a Salesforce bug that was introduced recently. What we had working perfectly before (last 2 months), is failing as of this evening.

 

Background: 

Created a change set in production this morning. Validated successfully. When trying to deploy the change set this evening, we get:

Failure Message: "System.DmlException: Insert failed. First exception on row 407; first error: INACTIVE_OWNER_OR_USER, operation performed with inactive user: []", 

 

The line of code that is throwing the error is a inserting a custom object. The owner of the custom object may be an inactive user.  From everything I have read, that is allowed.

 

Also, this used to run just fine before and the exact same code is throwing the exception.

 

This is only happening when the code is called from a Test Method (v24). 

 

Any ideas what could the cause? Has something changed around how Salesforce enforces inactive users?

 

Thanks,

Geek62

Scott_VSScott_VS

I'm not sure if inserting an object to an inactive user has ever been allowed. It's possiable that the user you were using in your test method used to be active, and has seen been inactive.

 

Why can't you change the test method to use an active user?

Geek62Geek62

Thanks Scott for replying.

 

The test class is using v24 of the APIs so we create all our data in the test method. It has always been the same. Nothing changed there at all in the test class. 

 

Also, that exact test class runs all tests just fine in the sandbox. 

 

I am 100% sure we have been able to make a Custom Object record owned by an inactive user in the past.

 

I tried this simple test below and the inActiveTest method is indeed failing! 

 

Do you (or anyone know) if Salesforce has changed the CustomObject ownership criteria recently? An inactive users not own custom object records now?

 

Thanks,

 

@isTest
private class TestingActiveInactive {

    static testMethod void activeTest() {
        User testSM1 = new User();
        testSM1.FirstName = 'test';
        testSM1.LastName = 'SM1';
        testSM1.isActive = true;
        testSM1.Forecast_Role__c = 'SM1';
        testSM1.Email = 'testSM1@test.com.testuser';
        testSM1.Username = 'testSM1@test.com.testuser';
        testSM1.Alias = 'testSM1';
        testSM1.CommunityNickname = 'testSM1';
        testSM1.TimeZoneSidKey = 'GMT';
        testSM1.LocaleSidKey = 'en_US';
        testSM1.EmailEncodingKey = 'UTF-8';
        testSM1.LanguageLocaleKey = 'en_US';
        testSM1.ProfileId = [Select ID From Profile Where Name =: 'System Administrator' Limit 1][0].Id;
        
        insert testSM1;   
    
        Test_Object__c c = new Test_Object__c();
        c.ownerId = testSM1.Id;
        c.Name = 'TestingActiveUser';
        
        insert c;
    }
    
    static testMethod void inActiveTest() {
        User testSM1 = new User();
        testSM1.FirstName = 'test';
        testSM1.LastName = 'SM1';
        testSM1.isActive = false;
        testSM1.Forecast_Role__c = 'SM1';
        testSM1.Email = 'testSM1@test.com.testuser';
        testSM1.Username = 'testSM1@test.com.testuser';
        testSM1.Alias = 'testSM1';
        testSM1.CommunityNickname = 'testSM1';
        testSM1.TimeZoneSidKey = 'GMT';
        testSM1.LocaleSidKey = 'en_US';
        testSM1.EmailEncodingKey = 'UTF-8';
        testSM1.LanguageLocaleKey = 'en_US';
        testSM1.ProfileId = [Select ID From Profile Where Name =: 'System Administrator' Limit 1][0].Id;
        
        insert testSM1;   
    
        Test_Object__c c = new Test_Object__c();
        c.ownerId = testSM1.Id;
        c.Name = 'TestingActiveUser';
        
        insert c;
    }
    
}

Geek62Geek62

I tried another simple test, this time, not in a test class.

 

Test_Object__c t = new Test_Object__c();
t.Name = 'InactiveUser';
t.ownerId = '005A000000XXXXXXX'; //inactive user
insert t; //this failed!

 

So, something has really changed where Salesforce is not allowing inactive users to even own custom object records.

 

In the past, I had run into this with Accounts, Cases, Opptys etc. where inactive owners were not allowed to own them.

 

Custom Objects is a whole new symptom.

 

Hasn't anyone else seen this?

 

I also tried different versions of the API to see if this is something that was introduced in a new version of the API. But I am getting the same error in v20, v21!

 

Can someone please let me know if I am halucinating?

 

Thanks,

Scott_VSScott_VS

I don't believe that kind of change went into affect for version 24, and backdating the versions in your code seems to be showing that it still doesn't work either.

 

The only major change (and it is a major change) to testing in 24 is that you no longer have access to data in the org outside of your test. However, you still have complete access to your Users, so I don't believe this is a problem. Try adding the @isTest(SeeAllData=true) notation to the beginning of your code and see it that fixes the problem. It's a longshot, but that might be what's causing it.

Geek62Geek62

Thanks Scott.

 

Yes, I know about v24 and how that impacted test data.

 

But, this problem is not really related to test code. I also tried a very basic test by creating a simple record (see my last post) and I am getting the same problem.

 

The question is: Has anything changed where Salesforce doesn't allow you to create custom object records which are owned by inactive users? I am sure this was allowed before (up until 12pm ET today it worked!)

 

If so, I think this will impact alot of Salesforce customers and not just us. 

 

Thoughts?

craigmhcraigmh

It wouldn't be the first time that an undocumented change that affected all versions caused issues like this.

jcaceresjcaceres

We are investigating this issue. As a workaround you can assign the owner using the user's sObject rather than the user ID. 

 

For example instead of using your code:

c.ownerId = testSM1.Id;

 

Use this code:

c.owner = testSM1;

 


amagaamaga

I'm finding some strange behavior with my unit tests that are related to this.

 

I insert a test user and a test object.  The object has a custom user lookup (not owner) and I assign the test user to that lookup.

 

When I first insert the user, I debug the isActive flag and it shows as true, but when I execute my code on my test object the isActive flag of the test user shows as false.

 

Does anyone have an idea as why this would happen?

dev_sfdc401dev_sfdc401

Is this resolved.. am having same problem while doing insert on custom object

 INACTIVE_OWNER_OR_USER, operation performed
with inactive user

JmthibeaJmthibea
I had the same issue.   Remember, the code deploys to a live production environment, so it is subject to contraints/manipulation from validation and workflow rules (via field updates).  I noticed, my test classes were inserting a Test User for the runAS() command, and I had just built a workflow rule to run "on insert/update",which would deactivate the user if a custom field did not equal 'ACTV'.  Existing classes were written before I built the workflow rule, which made the custom field value null.    So, when the existing test classes would insert the test user record, my new worflow rule was immediately deactivating them since null != 'ACTV'... Thus, the subsequent runAs(testUser) would throw the "inactive" user error'