Activity Forums Salesforce® Discussions Why Keyword “without Sharing” Is Introduced In Salesforce Apex?

  • Why Keyword “without Sharing” Is Introduced In Salesforce Apex?

  • Aman

    September 20, 2018 at 2:59 pm

    In Class Declaration If We Don’t Write Keyword “with Sharing” Then It Runs In System Mode Then

  • shariq

    September 20, 2018 at 3:01 pm


    Let’s take example, there is classA declared using “with sharing” and it calls classB method. classB is not declared with any keyword then by default “with sharing” will be applied to that class because originating call is done through classA. To avoid this we have to explicitly define classB with keyword “without sharing”.


  • Parul

    September 20, 2018 at 5:13 pm

    Without Sharing is reserved for cases where the User does not have access to the records, but there is a need to update them based on user input.

    Use the without sharing keywords when declaring a class to ensure that the sharing rules for the current user are not enforced. For example, you may want to explicitly turn off sharing rule enforcement when a class acquires sharing rules when it is called from another class that is declared using with sharing.
    public without sharing class noSharing {
    // Code here




  • Achintya

    August 30, 2019 at 10:09 am

    When we invoke some controller within another controller, If called or calling controller (only one) is attached with "with sharing " keyword then sharing rule will be enforced in both the class. to avoid that you need to use "without sharing" keyword in the controller in which sharing rules should not be enforced.

Viewing 1 - 4 of 4 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos