Sharing Keyword in Salesforce
Background:- Before I start with Sharing keyword and its importance, I would like to discuss in brief about UserMode and SystemMode. As main reason for using sharing keyword depends on the usage of Usermode and SystemMode. UserMode:- User mode is nothing but apex code running by respecting user's permissions and sharing of records. For example, logged in user does not have create permission and so he/she is not able to create a record.In Salesforce, only standard controllers and anonymous blocks like developer console run in user mode. SystemMode:-System mode is nothing but running apex code by ignoring user's permissions. For example, logged in user does not have create permission but he/she is able to create a record. We can think of SystemMode as GodMode, Apex code has access to all objects and fields— object permissions, field-level security, sharing rules aren't applied for the current user. This is to ensure that code won’t fail to run because of hidden fields or...