Questions tagged [apex-sharing]

Granting permission to User/Group of Users via Apex.

Filter by
Sorted by
Tagged with
2
votes
1answer
25 views

Manual Sharing Rules Mysteriously Removed

We also have an issue where Salesforce Support hasn't been a lot of help. We have some Apex code that was developed by a Salesforce contractor. We have a custom object and we have Apex code making a ...
0
votes
1answer
15 views

Apex “Manual” Sharing on Standard Object (Account): Sharing Gets Deleted

We use a Customer Community to dispatch Work Orders to partners. The partners use Customer Community Plus licenses. We share the Work Order using a community sharing set, but we cannot share the ...
0
votes
1answer
18 views

Creating share record based on recordId dynamically

I am working on a scenario of creating generic apex method of creating share records by using the recordId of an Object. I have a method which accepts recordId, userId, levelOfAccess and sharingReason ...
0
votes
1answer
19 views

Field Updateable on Create but Read Only on edit

I have a custom field on account object (Id number). I want a custom profile's users to be able to: On new account insert id number On edit i want this field to be read only, so as users of these ...
0
votes
2answers
39 views

Apex records sharing vs standard record sharing

I need to know what are the advantages of the Apex records sharing compared to the standard record sharing with sharing rules? When to use Apex records sharing over the standard record sharing?
4
votes
2answers
125 views

Apex class to be used for both with and without sharing

I have created a selector class on Campaign object to be used in with sharing context like below: public with sharing class CampaignSelector { public static Map<Id, Campaign> getCampaigns()...
0
votes
0answers
17 views

Queue members can not edit case record through Apex even though submitted record for approval is unlocked

I have two objects Contract and Case and if any cost update happens to contract through visualforce/lightning page, case trigger handler is fired to update also. Here are the recent changes done in ...
0
votes
1answer
36 views

Apex bulk sharing Batch class

I came across a new feature on Salesforce apex sharing where you can define a batch class and can associate that batch class to an Object. Whenever security settings changes for the object the batch ...
-1
votes
1answer
17 views

Overcoming sharing settings

I have a Owd for account object is Public read only.I want to give Public read/write access for particular profile using Apex code.Is it possible withsharing Keyword?If it possible please give some ...
0
votes
1answer
68 views

Apex managed sharing limits?

I've implemented a User Managed Sharing Using Apex and need to know are there any limits for Apex User Managed Sharing for standard or for custom objects?
0
votes
0answers
46 views

system runAs method to verify if the user can access a record

I have below test class which verifies whether a use have access to the record or not. The Campaign__C object's sharing setting is Private. However with below test class when I run the SOQL the 2nd ...
0
votes
0answers
104 views

isUpdateable method return false on without sharing class

I having a visualforce page with a controller(without sharing) I have tried both method: - Schema.sObjectType.Opportunity.isUpdateable() - Schema.DescribeSObjectResult - isUpdateable() Both of them ...
0
votes
0answers
17 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
25 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
160 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
204 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
39 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
114 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
66 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 ...
1
vote
2answers
273 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
707 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
26 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
425 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
858 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
355 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
49 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
226 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....
3
votes
1answer
469 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 ...
10
votes
1answer
2k 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
1answer
307 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
812 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 ...
0
votes
1answer
966 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
84 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
134 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
315 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
197 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
44 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
2answers
89 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
699 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
375 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
48 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
301 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
240 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
136 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
396 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
162 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
368 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
53 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
80 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
581 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 ...