Questions tagged [without-sharing]
Use the with sharing or without sharing keywords on a class to specify whether or not to enforce sharing rules.
19
questions
0
votes
1
answer
102
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' ...
3
votes
0
answers
551
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 ...
0
votes
1
answer
1k
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 ...
2
votes
1
answer
315
views
Inner Class Without Sharing not working as expected
I found this post (Sharing rules and Inner classes), which references documentation that inner classes do not inherit the sharing of their container class.
From the documentation:
Both inner classes ...
2
votes
1
answer
105
views
Classes with no sharing declaration don't behave the same as those "without sharing"
I had been under the impression that omitting a sharing declaration was equivalent to using "without sharing", but that appears to not always be true.
For example, if I have legacy code like ...
0
votes
1
answer
746
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 ...
1
vote
1
answer
748
views
Public VF page with a controller having “Without Sharing” is failing to update the record with Summer'20 Guest User Security Policy Enforced on org
I am working on a customer requirement POC where I would like to allow external users to update the record form any standard/custom object. In order to achieve this, I set up a public site/community ...
0
votes
2
answers
375
views
Without Sharing class failed on validation rule
Custom apex trigger initiates a change on opportunity(from within a without sharing static class).
Which than apply DML update operation.
Validation rule fails on opportunity.
The validation rule ...
12
votes
2
answers
539
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 ...
3
votes
2
answers
276
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 "...
2
votes
2
answers
717
views
Using Without Sharing apex class in a Managed Pacakge
Can we use Without sharing class in a managed package?
We have a scenario where we want to query recent activities of Account, Contact and Opportunity and Custom_Object__c whenever we receive an ...
1
vote
2
answers
759
views
User hits record lock error despite class without sharing
My users keep hitting a record lock error despite the class being defined as without sharing. My understanding is that without sharing allows locked records to be edited by any user. This class is the ...
0
votes
1
answer
100
views
how to call with inherited class in parent class
below is the code what i am trying is to fetch contact record in without sharing mode.
commented part has the problem and it showing
Method does not exist or incorrect signature: void
...
0
votes
1
answer
221
views
Component Error - access rights?
I have a Lightning component that works correctly when logged in as a SysAdmin. However, when logged in as a user with a different profile, the error below is received. I have without sharing set in ...
4
votes
1
answer
390
views
How do I find out if a field is updateable by the System?
I am running a batch process that is marked without sharing.
I would like to to take one course of action if the batch process can update a particular field, and another if not.
For example:
if (...
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 ...
1
vote
1
answer
670
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 ...
0
votes
1
answer
144
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!
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 ...