You need to sign in to do that
Don't have an account?
Elsa Roussel
Unit Test : Details: System.DmlException: Insert failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, portal account owner must have a role: []
Hello,
I have this errore while trying to deploy from the sand box to the production (no error in SB).
I'm setting up a new community with simple portal community licence (role are disable in this licence) and i'm fetching a existing user as the account owner :
adminProfile = [SELECT Id FROM Profile WHERE Name IN ('Administrateur système', 'System Administrator')].Id;
roleId = [SELECT Id FROM UserRole WHERE Name ='XXXX' ].Id;
List <User> ownerpossible = [SELECT Id, Name FROM User WHERE IsActive = True AND UserRoleId =:roleId AND ProfileId= :adminProfile LIMIT 1];
Any idea ?
(I've try this method http://blog.jeffdouglas.com/2010/09/02/error-portal-account-owner-must-have-a-role/ but the user doesn't have a role either)
thx
I have this errore while trying to deploy from the sand box to the production (no error in SB).
I'm setting up a new community with simple portal community licence (role are disable in this licence) and i'm fetching a existing user as the account owner :
adminProfile = [SELECT Id FROM Profile WHERE Name IN ('Administrateur système', 'System Administrator')].Id;
roleId = [SELECT Id FROM UserRole WHERE Name ='XXXX' ].Id;
List <User> ownerpossible = [SELECT Id, Name FROM User WHERE IsActive = True AND UserRoleId =:roleId AND ProfileId= :adminProfile LIMIT 1];
Any idea ?
(I've try this method http://blog.jeffdouglas.com/2010/09/02/error-portal-account-owner-must-have-a-role/ but the user doesn't have a role either)
thx
I hope you are using RunAs to create the portal user ? like below code:-
Option 1:- Try to use above code
Option 2:- Please add role on your user from which you are doing deployment.
Please let us know if that will help u
Thanks
Amit Chaudhary
Reference : https://www.xgeek.net/salesforce/to-fix-portal-account-owner-must-have-a-role-error-in-salesforce-community-unit-test/
If you get this error "UNKNOWN_EXCEPTION, portal account owner must have a role: []" it is because your admin user you are logged in as when executing the test does not have a role assigned since the admin user is the one inserting the account in your test. Add a role to your admin user before attempting to run the test.