Salesforce Asked by Koustubh on November 8, 2021
I have increased test coverage of a class in QA Sandbox and I am trying to deploy that test class to production. When I run the test class in QA Sandbox, there is no error. But when I am deploying it to production, I am getting an error 'Guest users cannot be record owners'
.
Here is a screenshot of the error:
The class has nothing to do with communities. I am not able to understand why I am getting the error in production and not in QA Sandbox.
The version of QA Sandbox and Production is Summer 20. I read that there were some changes in Summer 20 release regarding guest users (Release Notes). In release notes, there is a section Automatically Assign Records Created by Guest Users to a Default Owner
. Here is the link. I verified that this checkbox is checked in both QA and production.
I am not able to find a way to solve this error. I am not able to answer why I am getting the error when the class has nothing to do with communities. Also, why am I getting the error in production and not in QA Sandbox even though class has the same code? Please guide. Thank You!
This has to do with the test class quering users and assigning the ownership of records to the user queried. In your case the system is returing a community user. Change the query to return a particular user profile or insert a new user and use it to assign the record ownership.
Answered by sfdc786 on November 8, 2021
@Koustubh, I ran into this same issue today. I was deploying a single controller class for a lightning component that had nothing to do with communities and received the same error. I also already had default owners set for each community and had the community setting enabled to enforce the default owner for records created by guest users.
I "solved" this by disabling the community setting that enforces default owners for records created by guest users. It seems like this may be a bug as it appears to be doing the exact opposite of what the release notes provide for information.
Answered by Kevin on November 8, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP