Skip to main content

Questions tagged [without-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
0 votes
0 answers
63 views

Public experience site and safe-calling Apex without Sharing

my company security department has concerns about the Experience Page with Screen Flow and Apex without sharing class, and I am looking whether a different approach is possible. Domain Experience Page ...
zanstaszek9's user avatar
-1 votes
1 answer
86 views

With Sharing and Without Sharing scenario

I have recently started learning about apex security. I have one scenario where I'm not able to tell the exact outcome even after going through a lot of articles and youtube videos. Scenario: When '...
coder123's user avatar
  • 143
-1 votes
2 answers
172 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
0 votes
1 answer
49 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
179 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
834 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
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
2 votes
1 answer
618 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 ...
Morgan Marchese's user avatar
2 votes
1 answer
416 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 ...
Matthew Souther's user avatar
0 votes
1 answer
1k 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
1 answer
830 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 ...
Nilesh Dethe's user avatar
0 votes
2 answers
494 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 ...
shaked mezuman's user avatar
12 votes
2 answers
623 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
  • 137k
3 votes
2 answers
310 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
2 votes
2 answers
870 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 ...
Rahul Gawale's user avatar
  • 12.3k
1 vote
2 answers
860 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 ...
Steel Reserve 211's user avatar
0 votes
1 answer
128 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 ...
cloudZigZag's user avatar
  • 1,376
0 votes
1 answer
240 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 ...
Michele Kleinhomer's user avatar
4 votes
1 answer
476 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 (...
Charles Koppelman'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
886 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
0 votes
1 answer
152 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
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