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
Eric-∑Eric-∑ 

OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type: []

I created a public site and enable it for customer community login. When I login as a community user, I need to create an Account record. But everytime when I try to create an Account record as a community user, I get the error message saying "OP_WITH_INVALID_USER_TYPE_EXCEPTION, Operation not valid for this user type: []". I rememebered that there is no problem to create Account records with customer portal or partner portal, even if the customer portal doesn't have create permission, since we already run the apex class in system admin mode. But why we can't do that with community user? Did anybody encounter the same problem or know how to solve this problem? Any suggestions will be helpful. Thanks in advance!!

Vinita_SFDCVinita_SFDC

Hello,

 

In the error message, the class must have been provided where the error is occurring. Please share the code, else check if you are making any license related constraints in your code.

Eric-∑Eric-∑

Thanks for your information.

The code is quite simple, I just enable the community in our dev org, and create a community user. Then I logged in as the community user run a simple page, where I tried to create an Account record, but failed with the above error message.

 

The code is as simple as:

 

Account newAccount = new Account(Name = 'Test');
insert newAccount;

 Any idea?

Ghanshyam Kumar 9Ghanshyam Kumar 9
You don't have ownerID assigned to account while creating it.

OwnerId - It should have a user id and that user should have a role assigned.
Assign owner id to the account and you will be able to fix the problem.
Alec Perea-Martinez 16Alec Perea-Martinez 16
@ghanshyam has the correct answer. I couldn't believe it was this simple. I was struggling so hard to get a community user to create an account, but just adding the owner ID resolved this. Please mark Ghaanshyam as the best answer. Thank you so much!!