function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Case creation by Platform licensed User

    Whenever a custom object B is created a corresponding standard Case record has to be created. The user who creates the record of object B has a salesforce platform license. There is trigger which inserts case everytime a B record is created. Since the user has a platform license he will not be able to access Case. But what I did not understand is when the user creates a record of object B how does the trigger not fail and go on to create a Case even though the User cannot access Case?

Thank you,
Trigger code will run in system mode[god mode] irrespective of user settings. So platform user create able to create case record. Move your trigger logic/Case creation logic in a apex class with WITH SHARING mode, then call that apex class from the custom object trigger. Now it will run in the user mode, platform user won't able to create case record.
Thanks your reply Karanraj. I forgot to mention that the logic for inserting the Case records is in a class and it is defined with 'with sharing' .
David ZhuDavid Zhu
I ran into the similar problem. I use the following code to check if the object is accessible to create a new record.
 if (Schema.sObjectType.your_own_object__c.isCreateable()) 

I remember, during DEV501 training, I was told With Sharing keyword only works for Web service call from out side.
In Apex developer guide, in "Enforcing Sharing Rule", it says: 

Enforcing sharing rules by using the with sharing keyword doesn’t enforce the user's permissions and field-level
security. Apex code always has access to all fields and objects in an organization, ensuring that code won’t fail to run because of
hidden fields or objects for a user.

David ZhuDavid Zhu
I believe With Sharing only changes the visibility of the records in the object. It means with "With Sharing", user can only see the records he/she created or the subordinates created, or all records if user is admin.   ( I tested this).
With Sharing won't change the object or field permissions. It means the method can access to all objects and fields in the case of being called by a trigger.