Skip to main content

Questions tagged [with-sharing]

Use the with sharing or without sharing keywords on a class to specify whether or not to enforce sharing rules.

Filter by
Sorted by
Tagged with
-1 votes
2 answers
41 views

Why default mode of Apex class run as with sharing when used with LWC while this is not a case otherwise?

Suppose I have an object with OWD set to private and I have given Read/Create Permission to a standard user now that user can only see his records (In apex class I haven't defined any mode).While this ...
Priyanshi Maheshwari's user avatar
-1 votes
1 answer
65 views

How partner users with same account are getting access to each other's records

I want to check how two partner users with the same account are getting access to each other's partner record. Owd of user object - private No sharing rules on user object. Also, when i query ...
Anonymous 's user avatar
0 votes
1 answer
44 views

Will there any impact of Account Public read only to private in apex class failures

We have OWD for Account as Public Read Only, but there is a requirement that we need to make an account for Private. When we do that, the user will see only what they own and whatever they earn from ...
Basu's user avatar
  • 41
0 votes
1 answer
72 views

Validate OWD, with sharing, Profile, Permission Sets as Non - ADMIN user

I am trying to validate the OWD for an object that is Public/Read Write without Read permission at the object level for a specific profile user. To validate the results I created a new profile by ...
indrasen neelam's user avatar
1 vote
1 answer
359 views

Not getting access related errors while updating records from LWC and with sharing apex

I am trying to update records which I don't have update access on. I am expecting to get errors for such records but it updating successfully. my org object owd is public read only and profile access ...
Parmanand Shete's user avatar
0 votes
1 answer
154 views

Unable to pass checkmarx security review

When I use 'Without Sharing' Keyword with class in a managed package and install it in a destination org or sandbox, the code works fine but get error in the checkmarx report. If I replace 'without' ...
socove's user avatar
  • 3
4 votes
0 answers
739 views

With Sharing appears to be enforcing object level security and field level security

We ran into a strange issue today. We have an Apex trigger that is calling an Apex service class. The service class was using with sharing and in our testing, users were able to create records even ...
Swisher Sweet's user avatar
0 votes
1 answer
325 views

Changing Case Owner in With sharing class

I have few question on "with Sharing" and "without Sharing" keyword in apex, In my Org the OWD for case is Public read only. I have one class where i am updating owner id of the ...
Nitish Yadav's user avatar
0 votes
1 answer
2k views

Identify in which mode(System/User mode) the class is running

From the Salesforce security review point of view for the the app exchange app, we need to add the access checks while querying and doing DML operations. If we have a requirement that the SOQL/DML ...
Hemant Keni's user avatar
4 votes
1 answer
7k views

WITH SECURITY_ENFORCED and Security.stripInaccessible in a single SOQL

Premise: I followed WITH SECURITY_ENFORCED, Security.stripInaccessible and comparison before designing my Apex class for querrying a few records. Doubt: I implemented my SOQL as Security....
user43598's user avatar
  • 517
2 votes
1 answer
620 views

Aura Controller "with sharing" is still acting as without sharing and allows deletion

Current Setup: I have an Aura controller which uses "with sharing" and a method deletes a lead using the Id. I set up a user with profile with no Delete access. I have also revoked "...
Fahad Khan's user avatar
0 votes
1 answer
115 views

Class declared as With Sharing then why Permission check?

Can anyone please explain if the class is declared as With Sharing then why do we still need to check if the User has permission for SOQL or not or the object creatable/editable etc? Please clarify. ...
user91530's user avatar
1 vote
2 answers
3k views

User without CRUD permission is able to create record in 'With Sharing' class

I have a patient object , related to Account (lookup relationship). Profile 'Standard User' doesn't have CRUD permissions on the patient object. In Account trigger, I call call 'accounthandler.cls' ...
Manish Anand's user avatar
1 vote
1 answer
215 views

With sharing class and update record

I have a visual force page and its controller as follows: <apex:page controller="OpportunityBusinessService" tabStyle="Opportunity"> <apex:form> <apex:...
user2268467's user avatar
0 votes
1 answer
996 views

is omitted sharing in a class the same as with sharing?

I am bit confused about with sharing and without sharing in Apex. I have set OWD to private for Contacts and created sharing rules. If I login as an Admin, I see all the contacts. If I login with a ...
nSv23's user avatar
  • 554
1 vote
2 answers
859 views

Get records as per role heirarchy

I have a requirement of getting accounts with respect to role heirarchy. For eg. Lets say there are 3 roles A,B,C. Now when A user logins i want to fetch all the records of A,B,C user, similarly if B ...
Umesh Rathi's user avatar
12 votes
2 answers
602 views

Clean way to vary sharing at runtime in Apex?

I may need to make many @RestResource Apex classes run either with sharing or without sharing where that option is selected at runtime. But this approach (that I am using at present): /** * Allow ...
Keith C's user avatar
  • 136k
2 votes
1 answer
100 views

Do we have to force all FFLIB classes with `with sharing` keywords to pass security review?

I'm using FFLIB classes in my managed package and i just wanted to know if i should mark FFLIB classes use in my package with with sharing keyword to follow security review requirements ? Thanks,
Bryce's user avatar
  • 442
3 votes
2 answers
298 views

with and without sharing with innerclass

I'm working on a project that needs to change a lot of data that the user shouldn't see in the backoffice. So I'm wondering if I should put my entire class "without sharing". For now I'm creating a "...
Louis du Beux's user avatar
0 votes
1 answer
3k views

INVALID_CROSS_REFERENCE_KEY: Record Type ID: this ID value isn't valid for the user: (RecordTypeId)

I do know that we can use "without sharing" when we dont want to apply the sharing rules of the current user to set the values, but my class has nothing after access modifiers, just public class ...
Nagendra K S's user avatar
1 vote
1 answer
802 views

`sharing` / `without sharing` keywords inheritance behaviour

I have a doubt regarding sharing mechanism in Salesforce. If we have these classes: public without sharing class Ctrl1 { } public with sharing class Ctrl2 extends Ctrl1 { } By reading the ...
Luís Soares's user avatar
2 votes
2 answers
557 views

Sharing Setting - Contact - Controlled by Parent - Community - SOQL -Apex With Sharing

In my org, we have 5 contact matching 'dummy record'. When we use SOQL in community pages. It shows only one records. Sharing setting Contact : Controlled by Parent Account : Public read/write ...
pranil nimase's user avatar
0 votes
1 answer
430 views

Limit SOQL results using 'with sharing' in Controller does not limit returned data for Pricebooks

I am running a SOQL query in a controller where I have declared 'with sharing' at the class level. The returned results are not following the sharing rules setup for the current user. The sharing ...
binaryLady's user avatar
2 votes
0 answers
156 views

Community Plus User - Contact sharing via SOQL does not match List View

In my Visualforce Page, I just use the following code to get a name list of contacts that the current user can visit. public with sharing class TestClass{ public String getAllContactNames(){ ...
Leo Li's user avatar
  • 21
0 votes
1 answer
150 views

Not able to access CronJobDetail object when class is With sharing mode

I am not able to access CronJobDetail object when my class is in with sharing mode. Getting the below error: sObject type 'CronJobDetail' is not supported. Any idea? Thanks!
Riya's user avatar
  • 71
10 votes
1 answer
307 views

Read access denied: getQueryLocator(soql) vs. query(soql)

I am attempting to add pagination, and I followed this great article by Jeff Douglas. I am an admin so when I run the page it runs great, I can navigate forwards, back. When I log in as a user my ...
Steve MunLeeuw's user avatar
15 votes
3 answers
3k views

What's It Called: Inner Class Without Sharing?

I believe I have heard a specific term for this pattern, but I am not able to retrieve it from the foggy banks of my memory: public with sharing class OuterClass { public without sharing class ...
Adrian Larson's user avatar
  • 151k