Activity Forums Salesforce® Discussions What is Inherited Sharing keyword in Salesforce ?

  • Anuj

    Member
    October 5, 2020 at 4:16 pm

    If you specify inherited sharing Keyword on an Apex class, which allows the class to run in the sharing mode of the class that called it. Using inherited sharing enables you to pass security review and ensure that your privileged Apex code is not used in unexpected or insecure ways.

  • MOHIT

    Member
    October 7, 2020 at 7:53 am

    Use the <samp>with sharing</samp> or <samp>without sharing</samp> keywords on a class to specify whether sharing rules must be enforced. Use the <samp>inherited sharing</samp> keyword on an Apex class to run the class in the sharing mode of the class that called it.
    With Sharing
    The <samp>with sharing</samp> keyword allows you to specify that the sharing rules for the current user are considered for the class. You have to explicitly set this keyword for the class because Apex code runs in system context. In system context, Apex code has access to all objects and fields— object permissions, field-level security, sharing rules aren’t applied for the current user. This strategy ensures that code doesn’t fail to run because of hidden fields or objects for a user. The only exceptions to this rule are Apex code that is executed with the <samp>executeAnonymous</samp> call and Connect in Apex. <samp>executeAnonymous</samp> always executes using the full permissions of the current user. For more information on <samp>executeAnonymous</samp>, see Anonymous Blocks.
    Use the <samp>with sharing</samp> keywords when declaring a class to enforce the sharing rules that apply to the current user.

  • Marziya

    Member
    October 7, 2020 at 1:05 pm

    Using inherited sharing enables you to pass security review and ensure that your privileged Apex code is not used in unexpected or insecure ways.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos