+ Start a Discussion
Ken Koellner 1Ken Koellner 1 

Can a Site Guest User have Create permission to Event?


If you enforce object level CRUD in Apex code for the Site Guest User, will Event not be creatable?  It looks like there is no way to check access for Event.   I found the comment in the manual "With the public access settings you're allowed to set full create/read/update/delete (CRUD) permissions for all custom objects, and read and create on most standard objects. There are three standard objects – Products, Pricebooks, and Ideas – that are exposed as read only.".  That would imply so but there's no check box to check for that object on the profile.

I wrote the test below --
 
@isTest(seeAllData=true)  class KKExperSecurityTest {


  private static TestMethod void checkGuestUserEventPermissionTest()  {
    
    User myUser = [ select id from User where username = 'mysiteuser@mydevscheduler-developer-edition.na40.force.com'];

    Boolean myBoolean = Schema.Event.getSObjectType().getDescribe().isCreateable();
    System.debug('running as system user -- ' + myBoolean);
 

    system.runAs(myUser) {      
        
      myBoolean = Schema.Event.getSObjectType().getDescribe().isCreateable();
      System.debug('running as guest user -- ' + myBoolean);
 
    }  
  }   


}
And it printed--
19:24:44.0 (10012796)|USER_DEBUG|[9]|DEBUG|running as system user -- true
19:24:44.0 (40760779)|USER_DEBUG|[15]|DEBUG|running as guest user -- false