Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [apex-sharing]

Granting permission to User/Group of Users via Apex.

Filter by
Sorted by
Tagged with
0
votes
1answer
643 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
1answer
528 views

Selectively Deleting sharing rules

Hi guys I am trying to delete sharing rules on a custom object (say myCustOb__cj) based on if the user is a portal/community user or an internal user. If the user is a portal user then delete the ...
0
votes
0answers
8 views

Hide lead records from global search and list view including system admin

I have implemented lead conversion from apex class. I have done that correctly. But after the conversion I want to archive the lead(Hide the lead from list view). In standard lead conversion ...
0
votes
0answers
23 views

SharingRule is not being shown as RowCause in OpportunityShare record

I have granted a User access to an Opportunity record through an Opportunity sharing rule. Now I can see in the UserRecordAccess Object that the User has access to this particular Opportunity record. ...
0
votes
1answer
26 views

SFDX: How to pull SharingRules from scratch org to local?

I changed the CustomObject__c OWD to Private. I created a sharing rule through Apex trigger. When I pulled it, it only pulls the Trigger, Class, and CustomObject__c.meta BUT no sharingRule xml. That's ...
0
votes
1answer
359 views

Able to perform DML operation on Read only object from trigger running with sharing

I have a trigger which runs with sharing. All I am doing in this class is updating or inserting another sObject on afterInsert or afterUpdate. Trigger is running in system context Profile/user used ...
0
votes
1answer
46 views

Using without sharing methods inside with sharing class (with sharing applied)

I have a controller ControllerClassA which is with sharing. And i also have another class HelperClassB which is without sharing. I have a method inside a without sharing class HelperClassB which is ...
0
votes
0answers
28 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
69 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
43 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
35 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 ...
2
votes
3answers
422 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
2answers
128 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
182 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
143 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
285 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
72 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 ...
-1
votes
1answer
29 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
126 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....
9
votes
1answer
859 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 ...
3
votes
1answer
247 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 ...
1
vote
1answer
579 views

case share records are not visible in caseshare table

I have added case share using manual share(apex programming) and I could see the id from the case share table in debug logs after insert. I have verified everything including users access(community ...
0
votes
0answers
179 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 ...
13
votes
2answers
7k views

Communities Sharing Rules with Partner level access

So Im a little confused about the best way to share content within a salesforce community. We have a number of custom objects with content owned by community members, and our hope is to create "...
0
votes
1answer
681 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
68 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
61 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
201 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
154 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 ...
4
votes
1answer
1k 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
2answers
73 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
542 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
293 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
47 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
202 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
185 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
100 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
307 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
137 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
293 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 ...
5
votes
2answers
2k views

Is is possible to grant delete permissions using apex managed sharing?

I have Custom_Object__c with: Org-Wide Default Settings as: Private Object Permissions in the user Profile: Create, Read, Edit, Delete. I have a small development in Apex that is creating some apex ...
0
votes
1answer
47 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
71 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 ...
1
vote
1answer
330 views

Records sharing using Apex - [Records are inserted successfully but do not reflect in __share table]

Today I have encountered a wierd problem while sharing the records through Apex. Appreciate if someone can help me understand the root cause or faced the similar issue earlier. Flow of the Code is : ...
6
votes
1answer
3k views

Query a custom object's “__Share” in subquery

Is it possible to use a subquery to obtain a list of that object's __Share's? For example: ObjA has been manually shared via apex. At some point I may want to query information about ObjA and get a ...
0
votes
1answer
408 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
578 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
458 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 ...