Skip to main content

#Sharing Rules0 discussing

Access and Sharing Explained 

I have drafted an overview of access rights to objects and records. If you have any questions, feedback or corrections, please share them and I will update this overview.

 

Two Rules for Determining Access Rights

Determining a user’s access rights involves a two-step process:

  1. Object Access. First, determine whether the user has access to the object. If so:
    1. What types of access does the user have: read, edit, create or delete. 
    2. What level of access does the user have to each object field: none, read or edit? A user with read-only access to a given object can never edit any of the object’s fields, regardless of any field-level access they may have been granted.
  2. Record Access. Second, assuming the user has any type of object access, determine whether the user has access to a specific record. A few restrictions, which cannot be overridden or bypassed:
    1. If a user does not have any access rights to an object, the user will not have any rights to any record of that object.
    2. If a user does have access rights to an object, those rights limit what a user can do with every record of that object, regardless of how record access is derived. A user with read-only access to an object who owns a record of that object will be limited to read-only access to that record, notwithstanding their ownership.
    3. With a few exceptions note below, a user will have the same CRED rights to every record of an object and the same rights to every field of every record. There might be situations where a user with edit rights or above to an object may be limited to read-only rights to a specific record.

 

Master-Detail Relationships

In a master-detail relationship, the configuration of object access rights can diverge between the parent and child. A user could have edit rights to the child object and read-only access to the parent object, or edit rights to the parent object and no rights to the child object.. 

However, access to a child record is always inherited from and matches the user’s access to the parent record, subject to the user’s rights to the child object. This covers both whether a user has access to a child record and what types of rights the user has to the child record, as the user’s rights to the child record will be limited to its rights the parent record.

 

 

Understanding the rules described above will help when configuring access rights.

 

The next two sections explains how a user can be granted object access, how the user can be granted record access, and the types of access the user will have to each.

 

How to Grant Object Access

There are only two mechanisms that can be used to grant a user access to an object:

  1. Profiles. Every user must be associated with a profile. A profile can be configured to grant access to any type of object, with these options:  Read, Edit, Create or Delete, View All and Modify All. In addition, via the profile, different access rights can be granted to every field of the object: none, read or edit. Note that a new “View All Fields” setting has been added to make it easy to grant a profile the ability to view all fields with one checkbox, including future fields.
  2. Permission Sets. For object access purposes, permission sets can be configured exactly the same way as profiles, with the same settings. A permission set with object access can be assigned to a user to increase (not decrease or restrict) the user’s access to an object, access the user likely had not obtained via their profile.

 

How to Grant Record Access

Before continuing, let me reiterate one the restrictions on record access noted above, because Salesforce administrators may believe that record access is sufficient: If a user does not have any access rights to an object, the user will not have any rights to any record of that object.

 

Understanding and configuring record access is much more complicated than object access. As a general rule, each method of granting record access can be used only to increase which records a user can access or the types of access the user has, not to reduce access.

 

Super Powers

These two mechanisms for granting record access are what I think of as granting a user super powers:

  • Via a profile or permission set, a user can be granted System-Wide View All Data or Modify All Data rights, found in the System Permissions section. If so, that would give the user access to all records of all objects, either read-only or edit/full.
  • As noted above, via a profile or permission set, a user can be granted View All or Modify All rights to an object, which would give the user access to all records of that object, either read-only or edit/full.

 

Before continuing, let me reiterate another restriction noted above: If a user does have access rights to an object, those rights limit what a user can do with every record of that object. For example, a user who has View All rights to an object via profile/permission sets can never edit any record of that object.

 

Typical Methods for Granting Record Access

  1. Record Ownership. The first method by which a user obtains access to a record is through record ownership. Typically, ownership would be gratned if the object was created by the user, but ownership can also be transferred to the user later by another user with sufficient rights. (Note that the owner of a record can typically transfer ownership to another user, which is one way that a user may have more access rights to a specific record than other users with the same access to that object.)
  2. Organization-Wide Defaults. The next method for granting record access is using Organization-Wide Defaults (OWD) to configure either Public Read-Only or Public Read/Write defaults to an object. In that case, then every internal user (and external user, if so configured) would have read-only or edit rights to every record of that object. These OWD defaults are considered the baseline for granting access to records a user does not own.
  3. Role Hierarchy. Granting access via the role hierarchy is enabled for each object from the OWD setup page. (Role hierarchy is enabled by default for all standard objects.) If role hierarchy is enabled for an object, a user who is higher in the role hierarchy has access to every record of that object that everyone lower in the hierarchy either owns or which has been shared directly to them. However, the record access rights the more senior user will have is governed by their object access rights. Therefore, a junior user may have edit rights to the record but the senior user, with a different profile, may be limited to read-only rights. On the other hand, if the senior user has edit rights to the object and the junior user has read-only rights, the senior user can edit the records they gain access to via the role hierarchy.
  4. Sharing Rules. These rules are defined either by a record’s current owner or by record criteria and the rules identify which users or category of users will be granted access. Unlike role hierarchy, sharing rules can be limited to read-only access or can grant read/write access. Remember, there is no bootstrapping: a user whose profile grants them read-only access to an object will not obtain edit rights to a record they gain access to via a Read/Write sharing rule. On the other hand, a read-only sharing rule will act as a ceiling and limit a user to viewing a record even if the user has edit rights to the object via their profile.
  5. Manual Sharing. Other than how access is granted – one record at a time and manually – the configuration and impact of manually sharing a record works identically to how sharing rules work. A record can be manually shared with either read-only access or read/write access. 
    1. Manual sharing for an entire org must be configured on the OWD page. Manual sharing is not available for an object if the OWD default for that object is Public Read/Write. Finally, Manual Sharing must be enabled for each object but is typically enabled by default for all objects.
    2. Only certain users can manually share a record, such as a system administrator, current record owner, a user above the owner if role hierarchy applies and users granted “full access” to a record via another mechanism. Manually sharing of a record can be revoked and is impacted if record ownership changes.
  6. Team Access. Teams can be created for accounts, opportunities and cases. If a user is added to a record team, the user will gain access to the record. (The mechanism is slightly different for case teams.) The type of access the team member is granted can be read-only or read/write, depending on how their team membership is configured. The user’s team access will act as a ceiling on their access to the record. A team member with read-only team access who has edit rights to the object via a profile will be limited to read-only access. Similarly, a team member with read-write team access who has read-only rights to the object via a profile will be limited to read-only access, because their object access acts as a ceiling.

#Sharing Rules

0/9000

Hello,

I've completed almost the entire Admin Certification prep trailmix, but have been thrown off by something. I've been reading the official help documentation for Organization Wide Defaults and for Sharing Rules, but I still am still confused by one of the questions I encountered.

 

I was asked what OWD permissions must be set on the Opportunity object for the owner of an Opportunity to be able to create a sharing rule on it. I don't understand why the answer was "Public Read/Write".

 

I know that sharing rules are used to expand the visibility of objects to particular people that may not be able to see them. For example, you'd make a sharing rule dependent on a field, so if an Opportunity is in a particular stage, someone specific can see it.

 

So, I told myself that maybe "Public Read/Write" would make sense if someone was somehow unable to see Opportunity objects. But if the OWD for Opportunities is "Public R/W", then shouldn't everyone already have the ability to read and write all opportunities? Even if I put a permission set on someone to try to restrict their visibility of opportunities, I know that permission sets can only add visibility, not remove it. So if the OWD is already publicly visible, a permission set wouldn't be able to revoke that visibility from anyone, right??

 

Can anyone please help shine light on this for me? Is this a particular Opportunity-based quirk (maybe because having access to an Opportunity grants access to it's Account)? 

 

Lastly I'd just like to post what is written as the explanation for "Public Read/Write" on the help page:

For example, if Tom is the owner of Trident Inc., all other users can view, edit, and report on the Trident account. However, only Tom can alter the sharing settings or delete the Trident account.

So if everyone can already read/write to the record, what good does having the ability to change the Sharing Settings do? Does that simply mean Tom is the only person that can change ownership of the record?

 

Thank you so much in advance!!

 

#Salesforce Admin  #Sharing Rules  #Trailhead Challenges  #TrailblazerCommunity

3 answers
  1. Mar 6, 2024, 1:42 PM

    Hi @Michael Brown, thank you for responding!!

     

    The question was actually in the final "Admin Super Set" superbadge quiz. It's one of the quizes you can't retake, so I can't go back to show you, but it was one of the final questions in the whole trailmix which made it even more confusing. I may have slightly butchered the exact wording of the question, but I'm honestly confident that that is what it said.

     

    I appreciate your answer, I am still a little lost though and really wish I could just go back and see the question :( Everything you said makes perfect sense to me, but it still doesn't feel like it exactly matches what the question was asking me. I was/am still really confused by this question because it just seems backwards!

0/9000

Hi Everyone,

 

I'm trying to create a custom sharing flow for contact records. I would like to make all my contact records private to my service resources unless they have been assigned to this particular contact. I have created a custom object called resource participant which has the following fields:

  • Contact Lookup
  • Resource Lookup
  • Start Date
  • End Date

 

The purpose of the resource participant is to 'assign' a resource to a contact (in other words give the resource access to view this particular contact record for a specified time period)

 

I would like to create a flow so that when a 'resource participant' record is created, the contact's record is shared with the resource only for the duration specified in the resource participant record start and end dates. How would I go about creating this flow? 

 

https://www.linkedin.com/pulse/automate-sharing-records-salesforce-using-flow-alekhya-mandadi/

 

I have tried to follow a similar process to the attached article but I am getting stuck on configuring the assignment element.

 

Thanks in advance

 

#Salesforce  #Sharing Rules  #Flow

0/9000

I need to create a Sharing Rule that only allows Users to see Campaign Members where they are the record owner of the Contact or Lead that corresponds with the Campaign Member.

 

Sharing Rules don't support the formula criteria I would be using, and I'm not finding a 'CampaignMemberShare' object that I can reference in apex.

Is there another way I might be able to attack this? Am I missing something? Or am I out of luck on this requirement?

#Sharing #Campaign Members #Apex #Sharing Rules 

3 answers
  1. Nov 29, 2023, 9:20 AM

    @Dan Watkoski changing the organisation wide sharing setting for Campaign Members from Controlled by Campaign, to Controlled by Campaign Member, as mentioned by Martin, should be the solution to your request.

     

    What is your current OWD sharing for Campaign and Campaign Member?

     

    See also:

    Release Notes Summer 18

     

    I do understand your confusion, as the documentation, does not mention this update, it still considers the Controlled by Campaign setting only:

    Sharing Considerations

     

    See this screenshot for the options:changing the organisation wide sharing setting for Campaign Members from Controlled by Campaign, to Controlled by Campaign Member, as mentioned by Martin, should be the solution to your request.

    Otherwise as Svyatoslav mentions, this is more or less a Junction object, with Campaign on one side, and Lead or Contact on the other side.

     

    Sharing for a Junction object is always controlled by its Master, so I would not expect any Sharing table to become available in the future

0/9000

Scenario:- We have an object in which there is field called Guide(It is a lookup field to user). I need to update the owner of the record based on the value of the field. If the value of Guide field is "XYZ", the value of owner also should be "XYZ" regardless of who has created the record. It should be achieved through sharing rules.

3 answers
  1. Ruchit Patel (Cognizant) Forum Ambassador
    Aug 26, 2022, 7:30 AM

    Hello @Vaibhav Sharma sharing rules are used to grant access to records that's owned by uses with each other. If you want to update the Owner based on some criteria you can use either RT flow or you can use Apex if you just want one-time update of owners.

0/9000

Hi all,

my org-wide sharing is private on the opportunity.

 

Now I have created a sharing rule that share (Read/Write) opportunity with a public group.

 

I can assign to this public group using one of these profiles A or B

A is read-only on the opportunity

B is read/edit on the opportunity

 

The effect is that a user (in this pubic group) with profile A can only see the opportunities shared with the group. Instead, a user (in this pubic group) with profile B can see the opportunities shared with the group AND edit them.

 

Can you confirm?

 

I hope so!

 

Now, in case of a user with profile A (read-only) is correct he can't edit opportunities owned?

 

tks

3 comments
0/9000

Users need to see each others' activities/tasks but the 

Activity object doesn't allow sharing rules or object permissions in Permission Sets or Profiles. Does anyone know a workaround?

#Sales Cloud #Service Cloud #Nonprofit #Activities #Sharing Settings #Sharing Rules #Tasks

2 answers
0/9000

Hi All, Is it possible to add sharing rules using the metadata api via apex ? Please let me know if anyone has built such a thing before. Thanks!!

 

#Sharing Rules #Sharing Settings #Apex #Metadata

7 answers
  1. Tom Bassett (Vera Solutions) Forum Ambassador
    Nov 11, 2021, 5:42 PM

    Hello,

     

    I've actually just come accross a github repository that has a example code snippet you could use;

     

    https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataServiceExamples.cls

     

    Thanks, Tom

0/9000

I have created sharing rules based on user roles where members of the same roles can view and edit each other's records. However there are two lookup fields (Accounts and Product) that I would not want within the record to be edited by the non record owner (my object is private). I understand formula and lookup fields cannot be inserted by a criteria sharing rule. How can I then achieve this?

1 answer
  1. Manoj Nambirajan (Dell Technologies) Forum Ambassador
    Oct 19, 2021, 4:19 AM

    Once you open record visibility via sharing rules.. the next step to restrict the data edits.. can be via validation rules.

     

    You can have a rule like.. 

     

    $user.id <> Ownerid && (ISCHANGED(Lookup_field1__c) || ISCHANGED(Lookup_field2__c))

     

    Here we check if current user is NOT record owner AND one of the lookup fields are updated.. prevent it via validation rule

0/9000
2 answers
  1. Oct 19, 2021, 1:08 AM

     FavoriteMore Options

    Andrea Sloan (Personal) asked in #Sharing Rules

    Sharing rule and restriction on two lookup fields

    I have created sharing rules based on user roles where members of the same roles can view and edit each other's records. However there are two lookup fields (Accounts and Product) that I would not want within the record to be edited by the non record owner (my object is private). I understand formula and lookup fields cannot be inserted by a criteria sharing rule. How can I then achieve this?

0/9000