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
1answer
16 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
1answer
135 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
2answers
46 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 ...
11
votes
2answers
169 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 ...
2
votes
2answers
82 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 "...
1
vote
2answers
226 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
2answers
239 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
1answer
35 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
1answer
68 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
1answer
141 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
1answer
2k 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
1answer
161 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
1answer
97 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
3answers
1k 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 ...