Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [apex-sharing]

Granting permission to User/Group of Users via Apex.

0
votes
0answers
18 views

Apex Managed Sharing fails sharing Case with Community Plus user

Scenario: A 'Customer Community' License user logs into a community and creates a case, which is automatically assigned to a queue. A trigger on case invokes a future method (of a class declared ...
0
votes
0answers
15 views

Apex Sharing : AccountShare ImplicitParent

I am querying below AccountShare records - Select Id,AccountAccessLevel,Account.Name,RowCause,UserOrGroupId from AccountShare where UserOrGroupId='some_id' I am getting 2 records in which ...
0
votes
1answer
23 views

Lightning DataTable with CaseShare - Returning User or Group Name

I am using the lightning datatable in order to display the CaseShare data for a Case record within a lightning component. The feature works great however as the field UserOrGroupId on the CaseShare ...
0
votes
0answers
10 views

Permission Error when Auto-Sharing Salesforce File with Apex Trigger

I am trying to create an Apex trigger that automatically shares an attached Salesforce File with a user related to the record upon which the File was uploaded. I believe I have created a working code ...
1
vote
2answers
46 views

Trigger on Custom Object Share

I have a requirement whereby once a custom object record is created I must share this with AllInternalUsers. I have written a trigger on after insert to the custom object that this share record will ...
0
votes
2answers
33 views

Insufficient Access Right on “Without Sharing” Class

I'm trying to insert Sharing records via apex for the object "SBQQ__Quote__Share". The class that inserts the record uses "without sharing", but when i to insert the record i receive the error: ...
1
vote
1answer
24 views

Generic return for function

I have the following function that creates a share to a custom object: public static Order_Request__Share generateOrderRequestShare(Id orderRequestID, Id userId, Boolean readOnly){ System.debug('...
0
votes
0answers
27 views

Sharing records through apex with Public Group

I am sharing Opportunity records through OpportunityShare from Apex with Public Groups. When i checked the sharing button the record is being shared with that Group but after logging in as that user ...
0
votes
0answers
81 views

TooManyLockFailure : Too many lock failure 200 Trying again later

I have a requirement to provide a particular group of records to one user.But record sharing criteria depends on formula field. So, I'm not able to share through sharing rules. So, I have created an ...
1
vote
2answers
37 views

User unable to edit created Contract

OWD for Account and Contract is Public Read-Only. As we know that Account and Contract have Master-Detail relationship. Whenever a user creates Contract record the owner of the record is being ...
0
votes
1answer
16 views

Default external access Setting Issue for site Guest user

If I query this record I will get one record Query Editor & Anonymous window select id,Name from Account where Name='TestPartner' but In coding, system.debug('company domain---->'...
0
votes
1answer
44 views

Assign RowCause for Dynamic sOBject

I am trying to make an Apex controller that can work with any sObject. I cannot add Row cause for manual records though. Any help: // Create new sharing object for the custom object Job....
2
votes
1answer
131 views

For which scenario we need to use apex managed sharing?

We can control access to data at many different levels (OWD, Sharing Rule, Role Hierarchies) in salesforce. However, in which case we need to use apex managed sharing? Can you please explain with ...
9
votes
1answer
400 views

Schedule and Run a Report as an specific User from Apex

Background What we are trying to accomplish is to run daily some specific reports as an specific user. So far From a lightning component we are allowing the user to select a reports list. Once the ...
0
votes
0answers
60 views

Sharing Case Records with Customer Community Users

We have set up the community in Salesforce and business use case is that whenever the case raises from the external user and assigned it to an internal user for resolution than any action or updates ...
2
votes
3answers
240 views

Apex Based Sharing - Lead Share object

I am working on a requirement to achieve the below: Whenever a lead is created by a user: Check if that user is Rep Type (field present at user level), then add that user to Lead Share object with ...
1
vote
1answer
351 views

How to distinguish manual sharing and apex sharing in code level

I would like to distingish sharing between manual sharing and apex sharing For example please check below code: Code snippet List<Document__Share> lstDocSharesDelete1 = [select Id,...
1
vote
0answers
61 views

Community Sharing set field mapping

I am trying to work with Community sets and I am facing the following issues. I had created some sharing User:Contact = Case:Parent.Some_Lookup_Field__c and records were successfully shared I changed ...
1
vote
1answer
40 views

Finding sharing settings on custom objects

I want to know on custom object what is the sharing setting whether is Private, Public or Public/Read/Write. I have looked at the sharing table like CustomObject__Share SELECT Id,ParentId,...
1
vote
1answer
127 views

Share Pricebook record to the current user using Apex trigger or class or Flow

If there any Option to share the newly created Pricebook using Apex class to Current user. We have separate object(Opportunity Share) for Opportunity sharing like that do we have any object to share ...
0
votes
0answers
127 views

How the Custom Apex Sharing works in salesforce?

In my org, Case OWD is Private and Case has two child objects (Transaction1 and Transaction2) whose OWD is Private too. Transaction-1 and Transaction-2 object has lookup relationship with Case. I ...
1
vote
1answer
39 views

Fate of unsupported Lightning features?

Has Salesforce has said anything (officially or unofficially) about whether or not Lightning will support the below features that currently you have to switch back to Classic to manage? I have not ...
0
votes
1answer
460 views

field integrity exception: RowCause (Specified value is reserved and cannot be used)

I have a OWD Case is Private and its child Object (Payment also Private). I have Lookup relationship with Case and Payment object.. When Case is created its owner will changed as per the Case ...
0
votes
2answers
55 views

Give access read/write to child object when owner changes old to new in salesforce?

I have a Case Object, P1 and P2. P1 and P2 has an lookup relationship with Case. The moment Case owner changes, original case creator should get the Read access on Case and P1 and P2 object. In OWD, ...
0
votes
1answer
370 views

how to share a record to particular user

there is a lookup field with User object UserLookup__c : when the field is not empty , share that particular record to selected user in the lookup field. how can we achieve this 1. I think we can ...
2
votes
1answer
219 views

Grant “delete” access level on record using Apex trigger

I am trying to share a record of a custom object using an apex trigger. When trying to give the access level "All", an exception is thrown : System.DmlException: Insert failed. First exception on ...
-4
votes
1answer
45 views

When we use Apex sharing? what are the different situations we use? [closed]

We have Role-hierarchy, sharing rule, Manual sharing. When we go for Apex sharing? what are the different situation we use?
1
vote
0answers
113 views

Error while sharing Records with Apex sharing

I have two objects, pld and lead (relationship is such that lead is a parent and pld is child). When I'm changing the owner of pld objects then I want to share the lead with new owner of pld object, ...
1
vote
1answer
142 views

Want to share custom object records with Partner Community Users based on User's custom field

My custom object and User object, both are having a custom field named as State, I want to share custom object records with only those users who match with the State of the custom object's record. I ...
0
votes
1answer
76 views

Unable to access Contactshare records in test class as customer community plus portal user

Our contact OWD is Private When we convert an existing contact as a customer community plus user, he gets read only access to his own contact with the sharing reason 'Associated Portal User or Role '(...
0
votes
0answers
225 views

How to create Apex Case Sharing Rule in Partner Community

I have the following code which creates a CaseShare for a Partner Community User to share all cases across an Account. The UserOrGroupId is set to the Group of type 'RoleAndSubordinates' that is ...
0
votes
2answers
106 views

How to pull the Share table from a Lead and insert it into a Contact when the lead gets merged to that Contact

When a lead gets converted, if it has a contact with the same name, it gets merged using Dupeblocker. The share table from the lead gets lost, I'm trying to copy that table and insert it into the ...
2
votes
1answer
210 views

Use APEX to give users Sharing Access to a custom object

I'm trying to find out how to programmatically create a Sharing Access Rule for a custom object when an event occurs. For example, I have a Community active with some Portal users. Whenever one of ...
0
votes
1answer
41 views

How to share access of a private child to same access as parent, without using master-detail?

Given my object relationship below, how (without using master-detail between media and account) would I solve the need to share Media__c in a private Media__c model such that access to Media mimics/...
0
votes
1answer
61 views

Opportunity records are shared with users automatically

We are using a Visualforce page for creating Opportunity records. The Opportunity OWD is set to Private.We have salespersons field(users) being set on Opportunity Page while creating Opportunity. The ...
0
votes
1answer
302 views

Unable to deploy Apex-based sharing code due to sObject Type not Supported

I am trying to deploy some Apex-based sharing. Everything works fine in sandbox and code is 100% covered. I have a set of contacts (with a related User field) and a set of Project Task records (a ...
2
votes
1answer
501 views

Why can't I create this AccountShare in a community?

Here's the scenario. Customer Community user creates a record. A trigger fires, calls into a without sharing class which inserts an AccountShare record. AccountShare is not accessible to community ...
4
votes
1answer
252 views

What exactly happens when a share record is inserted?

We have apex sharing all over our project. When we developed and tested it in a Developer sandbox everything went nice and smooth. Now, in full sandbox this apex sharing seems to be the bottleneck. It ...
0
votes
2answers
201 views

Can we restrict records that are visible to a profile using custom Apex Sharing rules?

How can we restrict 1 particular Opportunity record type records using Apex Sharing rules for a profile?
2
votes
0answers
75 views

Apex Sharing to multiple individual users throws duplicate row error

Scenario I have Community users that I need to share some account records to, where the Account that the Community user is linked to is referenced by a lookup field on the Account record to share.I ...
0
votes
1answer
547 views

Creating sharing rules through apex not manual sharing

Is it feasible to create sharing rules through apex , not manual sharing of records? Can someone please let me know if that can be done?
0
votes
1answer
252 views

Partly sharing detail records of a master-detail relationship

In our data model, we have several objects that are details of account (master-detail) relationship. I want a profile to have access to the records of Object A and B if they are the owner of the ...
0
votes
2answers
294 views

Best way to share among multiple Roles/Profiles

Scenario: I have a requirement where I need to share records of some custom objects with users whose role could be anything say like region wise sharing. What could be the best way, till now in my org ...
0
votes
1answer
53 views

Available Objects for Apex Sharing [duplicate]

I was using Apex Sharing and it was working fine, but then I noticed that for some objects when I use CustomObject__Share it says 'Entity is not org-accessible'. I tried to google it, but wasn't able ...
1
vote
1answer
472 views

Share Child Record When parent record is shared

I have two Object Let's say Object A and Object B, Both are related with Lookup relationship, and Both are set to Private In OWD setting. Now When I share parent record I would like to share all it'...
4
votes
1answer
962 views

How to share object records to customer community users?

I have a requirement to share a custom object records to customer community users. The opportunity object has Event Booking and contact roles as related list. Eg: There is an opportunity called Test ...
0
votes
1answer
123 views

Why Apex Sharing [closed]

I am getting confused when we need apex sharing. Sales-force has Sharing rules(criteria,owner-based,manual),so what is the use of Apex sharing. Somebody please provide usecase/example when we need ...
1
vote
1answer
1k views

Communities - sharing options

At the moment we have a customer portal and we are looking to move to communities. The Customer Community license and the Customer Community Plus license offer different options for the sharing of the ...
1
vote
2answers
863 views

Apex Sharing Delete for Account

I have created two fields Assign Rep and Sales Manager which is having lookup with User in Account Object. I am sharing records using Apex. I have written one trigger for that. Now the problem is if I ...
1
vote
1answer
485 views

Customer Community Using Apex Sharing [duplicate]

I am trying record sharing through apex. But when i am giving sharing setting to Customer Community User it is throwing this exception FIELD_INTEGRITY_EXCEPTION, field integrity exception: unknown ...