13

Customer Communities users do not have access to the full sharing model and therefore can't be added on a __Share record. The only way to share a record with a Customer Communities user is through Sharing Sets and Sharing Groups.


12

This is perfectly possible. You are just using the wrong syntax. This will work: SELECT ID, Name, (SELECT ID, UserOrGroupdID FROM Shares) FROM ObjA__c WHERE ID = :someId; In order to find the right child relationship names, I always use the Schema Explorer in Eclipse. By browsing to an object and then selecting 'Child Relationships' you can find out the '...


11

I want to sketch out a possible design, as this is a question I've been turning over myself. For the record, I have not had time to build this out myself, even as a proof of concept, but I think something along these lines would work. See proof of concept at the end of this post. As an introduction from a previous question of mine on a similar topic: The ...


7

Each Partner Community user associated with the same account gets a unique Role. When a Partner Community user registers from say, Acme Widgets, that user gets the role Acme Widgets User or something of the sort. Every other user who registers related to the Acme Widgets account also gets that role. Users related to other accounts get their own unique role ...


6

A simple use case which comes to my mind could be as follows: At an organization, HR person conducts the interviews of candidates. HR person wants to share candidate's profile to an Interviewer. Consider, OWD of Candidate object is Private. Here, you can think that HR person would always create candidate record and in the candidate object, a Lookup field ...


4

Customer Communities users do not have access to the full sharing model and therefore can't be added on a __Share record. The only way to share a record with a Customer Communities user is through Sharing Sets and Sharing Groups. Source


4

Turns out Case sharing wasn't enabled. To do that, you will need to change organisation wide defaults (Security Controls>Sharing Settings), Case object 'Default External Access' to Private.


4

To determine the sharing mode for an apex class the system first looks for a sharing declaration, e.g. with or without sharing, and uses that. If it's not found it inherits the sharing declaration from the caller. So in your case, yes, that would do what you want. From the docs The sharing setting of the class where the method is defined is applied, ...


4

What exactly is happening when a share record is inserted? Is there some huge process behind the scenes that also recalculates all child records sharing(in case of Master-Detail)? Depending on the sharing model you're using, there's AccountOwnerSharingRule and AccountShare. Additionally there might also be OpportunityShare, a ContactShare and a CaseShare. ...


4

Without seeing your code, it's a bit difficult to fully diagnose your issues. I can share some of my experience with apex managed sharing in community plus orgs and suggestions on architecture that you may find helpful. First, let me say that while your transaction may have been initiated from the community side, Apex triggers and other code runs from ...


4

Unfortunately, Custom Sharing Reasons are only available for custom objects. For standard objects, the only Row Cause you can use is Manual in Apex, so there is no way to see the difference between 'user manual' sharing and apex sharing the standard Document object you are using. See the documentation: Apex sharing reasons and Apex managed sharing ...


4

I had the same requirement once. So what we did is we had a class that executed the query to be abstract and we created instances of its successors, that determined the sharing model. This way you still only one query to maintain and a single entry point, but you're free to switch the sharing context on flight. For your case this will look something like ...


3

No. Sharing is to grant access not restrict it. The only way to restrict record is using OWD. The easiest way to think about it is: If even ONE person should not have access to any single record of an object then the OWD for that object must be set to Private. Access is then granted by all of the various sharing rules, criteria etc. So in your case,...


3

The share records are entries in the sharing tables for records present in the database. So you cannot have duplicate share records i.e. You can't create two share records for the same account and user(there is an exception, lets wait for it!). So you are creating acountShare records for both 'Sales Manager' and 'Assign Rep' users. The apex share records you ...


3

The user needs to have the 'Modify All Data' permission. From the documentation Apex managed sharing provides developers with the ability to support an application’s particular sharing requirements programmatically through Apex or the SOAP API. This type of sharing is similar to Force.com managed sharing. Only users with “Modify All Data” ...


3

You should use the 'with sharing' keywords in your VF page controller class declaration. This enforces sharing rules as Apex, by default operates in system mode. From the documentation 'You have to explicitly set this keyword for the class because Apex code runs in system context. In system context, Apex code has access to all objects and fields— ...


3

The only other method for sharing custom objects that may suit your needs is Apex-Based Sharing. However, it's not perfect, because you can't create triggers on sharing tables to replicate the rules appropriately, so you'd have to run a scheduled process every once in a while to sync up the tables. In other words, users will not have real-time access to the ...


3

Apex Managed Sharing is designed to allow developers to specify business rules in terms of special sharing. For example, perhaps sales users should only be able to see marketing material for active campaigns. Or maybe those sales promotions are shared to specific users based on their location or profile. Maybe support needs to see extra information for ...


3

The doc is quite explicit that All may only be used by Force.com Managed Sharing The All access level can only be used by Force.com managed sharing. You are using Apex Managed Sharing - that is different from Force.com Managed Sharing The distinctions are covered here and summarized below: Force.com Managed Sharing has three components: Record ...


3

I would ideally write a Trigger on After Insert/After Update, and create ContractShare record with edit access. But, You cannot create an Apex Sharing for Contract. Also, Account and contracts are tightly coupled. Which means you have to give read-write access to Accounts to get Edit Access on contracts. I would handle it using Sharing rule based on ...


3

Because of M-D relationship of the Account and Contract, if Account has Edit access then Contract will automatically have Edit access. As Contract is Detail object so ownership is governed by Account owner. Best way to handle this is, when Account owner is getting changed then create a trigger to add previous owner as Account Team member of that Account and ...


3

If you want a method that can be used from two different contexts with or without sharing applied, the right approach is to put that method in a separate class that is declared as "inherited sharing", then simply call that method from the classes that are with or without sharing as required. The method will then apply or not sharing rules. public inherited ...


3

All of the notes in the docs apply: Apex sharing reasons and Apex managed sharing recalculation are only available for custom objects. Every time a custom object's organization-wide sharing default access level is updated, any Apex recalculation classes defined for associated custom object are also executed. The object’s organization-wide default access ...


3

One way would be to use inherited sharing instead of specifying the class using with or without sharing. public inherited sharing class CampaignSelector { public static Map<Id, Campaign> getCampaigns() { Map<Id, Campaign> campaignsByIds = new Map<Id, Campaign>([ SELECT Id, Name ...


3

Note that both of them create share records under the hood. Most of objects in salesforce (exception may be a detail object in master-detail relationships) have a junction object with name __share that holds share records. It’s advisable not to use apex sharing unless you absolutely need it and use the platform sharing features. This is because you can do ...


3

The advantage of Apex sharing is that you can calculate sharing conditions that otherwise cannot be done by standard and criteria-based sharing rules. For example, you could base sharing on an web service call, a separate business logic sharing table, standard or custom fields, etc. For the majority of use cases, the various sharing systems in Salesforce ...


3

From the Manual Sharing section of the document "A Guide to Sharing Architecture" https://developer.salesforce.com/docs/atlas.en-us.dat.meta/dat/dat_components.htm Manual sharing is removed when the record owner changes or when the sharing access granted doesn't grant additional access beyond the object's organization-wide sharing default access ...


2

Salesforce support got back to me saying this is a bug on their query optimizer and as a workaround the LIMIT clause can be added to the query.


2

Currently one has to manually share PriceBook record. Although the Pricebookshare object exists, but it is not accessible.


2

Bit late to the party, but since this was the top hit on google when I ran into this issue, I guess it is still relevant. As per the documentation, all manual shares are removed when the owner changes. This also applies when using auto-assignment rules, which seems to be the case in the example. Placing the sharing code in an after update trigger solves ...


Only top voted, non community-wiki answers of a minimum length are eligible