With Sharing & Without Sharing in Apex | Chapter 46 | Salesforce Developer Masterclass

Поділитися
Вставка
  • Опубліковано 30 січ 2025

КОМЕНТАРІ • 25

  • @sameershaik7023
    @sameershaik7023 9 днів тому +1

    Default Sharing Behavior:
    If you do not specify with sharing or without sharing in the class definition, the class does not enforce or ignore sharing rules explicitly. Instead, it runs in the sharing context of the caller (the user or system executing the code).
    This behavior can vary:
    System context: If the caller is a trigger or a system-level execution, the default behavior is to ignore sharing rules.
    User context: If the caller is running as a user through an Apex transaction like a Visualforce page, LWC, or API call, the default behavior may respect sharing rules unless overridden.

  • @amitpaple
    @amitpaple 4 місяці тому +1

    Hi Himanshu
    Basically Apex class always execute in system context i.e. Apex code has access to all objects and fields irrespective of the logged in User, hence by default it will be without sharing.

    • @salesforcemakessense
      @salesforcemakessense  4 місяці тому

      @@amitpaple yes 👍

    • @amitpaple
      @amitpaple 4 місяці тому +1

      @@salesforcemakessense Thanks alot for providing such valuable content. Haven't come across any UA-cam content where Salesforce concepts are explained so beautifully 😍

    • @salesforcemakessense
      @salesforcemakessense  4 місяці тому

      @@amitpaple thank you Amit, happy to see your progress 🙂

    • @KaranSh-t9w
      @KaranSh-t9w 3 місяці тому +1

      Hi, I am Karan.
      It is clear by default it is Without Sharing. Then what is the difference between Without Sharing and Default. Meaning what is the use of 'Without Sharing' keyboard even if we can achieve 'Without Sharing' features even without using it? Please answer

  • @KaranSh-t9w
    @KaranSh-t9w 3 місяці тому +1

    Hi, I am Karan.
    It is clear by default it is Without Sharing. Then what is the difference between Without Sharing and Default. Meaning what is the use of 'Without Sharing' keyboard even if we can achieve 'Without Sharing' features even without using it? Please answer @Himanshu

    • @salesforcemakessense
      @salesforcemakessense  3 місяці тому

      So, if you do not explicitly mention the sharing keywords like "with sharing" or "without sharing" in a class declaration, the class runs in the default mode, which depends on where the class is invoked from.

  • @vishal_gadhave
    @vishal_gadhave 5 місяців тому +1

    Himanshu, if i want to apply object and field level security then does with sharing take care of it ?
    Or I need to use with user_mode in soql ?

    • @salesforcemakessense
      @salesforcemakessense  5 місяців тому

      FLS won't be taken care via with and without sharing. We will cover this topic later in the curriculum and that will clear your thoughts/doubts around this.
      But, yes you need to add special keywords in SOQL to achieve that or write some additional code.

  • @vulavalaramasiva5699
    @vulavalaramasiva5699 7 місяців тому +1

    Good content

  • @harijami2922
    @harijami2922 7 місяців тому +2

    Hi Himanshu, this was good content but if you explain with any real time scenario it will be more helpfull

    • @salesforcemakessense
      @salesforcemakessense  7 місяців тому

      I understand, for now this is only to brief you about the keywords and their use case.
      Will make something around real time as well but separately :)

  • @abhaypatle9380
    @abhaypatle9380 5 місяців тому +1

    By default Apex classes runs on system mode, which means that the classes will not run in any of the user context and since we haven’t provide any sharing hence that would be equivalent to without sharing
    Ans: Without Sharing

  • @ABHI_316
    @ABHI_316 4 місяці тому +1

    i am sharing all your video with keyword "with sharing "😁

  • @ajaymudekar2734
    @ajaymudekar2734 7 місяців тому +1

    without sharing

  • @rajeshbandaruu
    @rajeshbandaruu 7 місяців тому +1

    Apex class by default without sharing

  • @YodhaNandan
    @YodhaNandan 6 місяців тому +1

    Without sharing