You need to sign in to do that
Don't have an account?
Baird_S
Cannot test as user of type guest? Should I care?
I've got a complicated controller/pages package which I've been testing using runas(), in order to make sure that the guest profile has access to all the fields and objects it needs to. My code:
//TRY TESTING THIS FOR THE WATERGRASS WEB PROFILE Profile p = [SELECT Id FROM Profile WHERE Name='WaterGrass Web Profile']; user u = new User(Alias = 'WGWeb', Email='WGWebUser@testorg.com', EmailEncodingKey='UTF-8', LastName='WGWebUser', LanguageLocaleKey='en_US', LocaleSidKey='en_US', ProfileId = p.Id, TimeZoneSidKey='America/Los_Angeles', UserName='WGWebUser@testorg.com'); insert u; System.runAs(u) { CODE TO BE TESTED }
But in my most recent deployments, I run into this error: Insufficient Access ...: Cannot insert a user of type guest.
My questions:
- Is this a new error type?
- Is there some easy fix?
- Does it matter whether I test using runas()? I'm curious whether you other developers use this.
Thanks for your input,
Baird
Inserting the user record is not required, so just comment out that insert statement & it will work fine.
For more info on this topic, refer to Using the runAs Method
Yeah, that's what I did. Thanks.