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
AbAb 

INACTIVE_OWNER_OR_USER Error

Hello,

I have a Code like below
 
List<CustomObject1__c> XYZList = new List<CustomObject1__c>();
        
	for(Account c:[SELECT Name, OwnerId, Description, Industry, Type, Website
			FROM Account limit 9999]){
                CustomObject1__c XYZ = new CustomObject1__c();
		
		XYZ.Target_Account_Id__c = c.id;
		
		XYZ.Name = c.Name;
                XYZ.OwnerId = c.OwnerId;

		XYZ.Description__c = c.Description;
                XYZ.Industry__c = c.Industry;
		XYZ.Type__c = c.Type;
		XYZ.Website__c = c.Website;

                
		XYZList.add(XYZ);
         }

        if(XYZList.size()>0){
            insert XYZList;
        }
This gives me below error.

I have added below lines at top of code but in vain
 
Profile objProfile = [Select Id, Name from Profile where Name =: 'System Administrator' limit 1];

	User objeUser = [Select Id, ProfileId from User where Id=: UserInfo.getUserId()];

Line: 38, Column: 1
System.DmlException: Insert failed. First exception on row 71; first error: INACTIVE_OWNER_OR_USER, operation performed with inactive user [005b0000000YntB] as owner of 01I8E0000008ks3: []


If i activate the user, it is running Ok, but this is not the solution i seek.

Thank you for suggestions
 
Best Answer chosen by Ab
ManojjenaManojjena
Hi Sandrine ,
Do one thing check in work bench whether the user is active or not ?

[SELECT id,isActive FROM User WHERE id=:'005b0000000YntB']
Login with below link give your credential and select SOQL  select user object and copy paste belwo query check whether the user is active or not if not then activate the user .
https://workbench.developerforce.com/login.php

Let me know if it helps !!
Thanks
Manoj

All Answers

Sampath KumarSampath Kumar
Hi Sandrine,

I think you are assigning the owner who is inactive to the custom object record.

If we assign inactive owners to the record, we will get this error. We can assign only active owners to the records.

Mark this as best answer if this answers your query.

Regards
Sampath 
AbAb
The owner i am assgning is my own account which is active.
 
Profile objProfile = [Select Id, Name from Profile where Name = 'System Administrator' limit 1];

	User objeUser = [Select Id, ProfileId from User where Id=: UserInfo.getUserId()];

 
Sampath KumarSampath Kumar
Hi Sandrine,

Can you please post your complete code because error shows line #38 column 1 and your code shows only 23 lines.

As we are retreving 9999 accounts, there may be chances any of the account owner is inactive,

Regards
Sampath 
ManojjenaManojjena
Hi Sandrine ,
Do one thing check in work bench whether the user is active or not ?

[SELECT id,isActive FROM User WHERE id=:'005b0000000YntB']
Login with below link give your credential and select SOQL  select user object and copy paste belwo query check whether the user is active or not if not then activate the user .
https://workbench.developerforce.com/login.php

Let me know if it helps !!
Thanks
Manoj
This was selected as the best answer
AbAb
Hello,

Acutally the Problem was with the line 9
XYZ.OwnerId = c.OwnerId;