Stack Exchange Network

Stack Exchange network consists of 174 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

Questions tagged [apex-sharing]

Granting permission to User/Group of Users via Apex.

0
votes
0answers
32 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 ...
0
votes
0answers
30 views

Querying for ContentDocumentId returns resutls whereas ContentDocument.Title doesn't

I have a VF page in a community that queries for files in the ContentVersion table. If I run the query like so... return [SELECT Id, Title, Description, Checksum, ContentSize, PathOnClient FROM ...
1
vote
2answers
33 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
15 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
24 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
83 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
291 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
32 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
2answers
154 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
236 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
54 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
33 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
101 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
124 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
37 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
410 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
49 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
287 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
178 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
89 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
128 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
73 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
200 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
97 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
176 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
40 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
59 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
268 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
474 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 ...
3
votes
1answer
208 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
167 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
69 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
524 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
234 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
226 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
50 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
434 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
906 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
117 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
784 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
452 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 ...
0
votes
1answer
121 views

Deleting a Shared Record using Apex Sharing

We have a requirement where a particular record of an Application object should be shared to either an assigned representative or a Sales Manager. These are two fields which are created on Application ...
0
votes
1answer
1k views

Edit Permission on Field with Particular Record Type for Selected Users

Want to do : Give Edit permissions for "Field1__c" on only Record Type = "Record_Type1" for Standard object to particular users (u1, u2,u3) only. All other users will Read Only for that field on ...
1
vote
1answer
540 views

Enable apex sharing reason

The apex sharing reason related list is absent in the object setting page. How to enable apex sharing reason in a sandbox. This is a detail object in a master detail relationship. Thanks in advance.
0
votes
1answer
50 views

Share record behaviour

On a learning perspective, how does the sharing records work when it comes to apex based sharing. For a given user and given record, can there be multiple share records of the same access level. Can ...
1
vote
1answer
291 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 : ...
0
votes
1answer
124 views

Insufficient privileges for sharing projects

I have a button to share projects but if the user isn't a sysadmin, neither ownerid, neither has the 'ModifyAllRecords' permissions, system shows an error message Insert failed. First exception on ...
1
vote
1answer
845 views

DML operation INSERT not allowed on CaseShare when deploying from Developer Sandbox to Developer Pro

I have this case trigger handler, works fine in sandbox: CaseShare[] casesShar = new CaseShare[]{}; for (case c: cs){ if(c.OwnerId!=null && oldCaseMap.get(c....