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.
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 Thanks alot for providing such valuable content. Haven't come across any UA-cam content where Salesforce concepts are explained so beautifully 😍
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
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
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.
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.
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
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.
That's right.
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.
@@amitpaple yes 👍
@@salesforcemakessense Thanks alot for providing such valuable content. Haven't come across any UA-cam content where Salesforce concepts are explained so beautifully 😍
@@amitpaple thank you Amit, happy to see your progress 🙂
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
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
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.
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 ?
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.
Good content
@@vulavalaramasiva5699 thanks 🙏
Hi Himanshu, this was good content but if you explain with any real time scenario it will be more helpfull
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 :)
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
@@abhaypatle9380 perfect! 👌
i am sharing all your video with keyword "with sharing "😁
@@ABHI_316 haha thank you 🙏
without sharing
👍
Apex class by default without sharing
👍
Without sharing
@@YodhaNandan 👌