2

We are creating a managed package and have submitted for Security review process. We had implemented CRUD-FLS check on all the objects we had used within our application except EVENT.

But we had checked the CRUD-FLS for all the possible Parent object for Event.

How do we implement CRUD-FLS check for Event object particularly for Site Guest User?

We wrote the quick test below which uses setAllData=true so it could run as the site guest user….

@isTest(seeAllData=true)  class KKExperSecurityTest {
  private static TestMethod void checkGuestUserEventPermissionTest()  {
    User myUser = [ select id from User where username = 'clicktoschedule@catdevscheduler-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);
    }  
  }   
}

The test prints…

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.