Episode 9. Sharing Salesforce CRM data with your Partners (PRM)

Your partners are your external users who could be anyone who works directly with your business and you as a brand see the need to share your operations CRM data with them to be able to a.) colloaborate and b.) share for operational reasons so that your external partners can work onthem. And just to underline → your parnter users can be anyone from the listed actors Dealers, Finance advisors (agents), Distributors etc

Source mohit :D

Let’s try understand how the partners (users) associattion with your businesss (internal CRM) looks like —

In general, Salesforce supports thes 5 different ways to control data accesss and ensure right person with access sees only what’s granted:

  1. Organization wide access (baseline line)
  2. Expand data access vertically using Roles hierarchy
  3. Expand across using sharing Rules
  4. Manual Sharing
  5. Apex Sharing (programatically)

However with partner relationship managment or Customer Communities, there exists the need to share your internal Sf CRM with your parnters therefore salesforce add on top of stack few more ways to collaborate along with existing ones.

Option 1:

  1. Using Sharing sets: A sharing set grants site users(partners) access to any record associated with an account or contact that matches the user’s account or contact. this is present under Setup Digital Experience → Settings — Sharing Sets. For example, grant partners access to all cases related to an account that’s identified on the users’ contact records. 3 important things to remember
  • Sharing sets → Only applicable to those objects which shares a parent child relation with Account or contact.
  • Does not apply to Objects where the organization-wide sharing setting of Public Read/Write (as access is already open default)
  • Record access granted to users via. sharing sets isn’t extended to their superiors in the role hierarchy.
Source: Mohit
Source Mohit

Note: You can only have one sharing set per profile.

2. Sharing Groups: This is more of an add on — Share groups allow you to share records owned by high-volume Experience Cloud site users with internal and external users. Activate it and use it.

source: Salesforce

Option 2:

Apex managed Sharing (To implement dynamic nature of routing)

To access sharing programmatically, you must use the share object associated with the standard or custom object for which you want to share

Share a Case object or any standard or custom Objects using Apex Managed Sharing :

This logic can be run under anonymous apex window in dev console to see th output or can be part of trigger or your process builder calling apex.

caseShare csShr = new caseShare();
csShr.caseId = ‘50009000001QseDAAS’; // record Id
csShr.UserOrGroupId = ‘00G09000000lbhAEAQ’; // group Id (
infor: this is somthing in case of partnr user salesforce maintains internally, see below to undertand how you can get this)
csShr.CaseAccessLevel = ‘Read’; (this can be read or write)
csShr.RowCause = Schema.CaseShare.RowCause.Manual;
Database.SaveResult sr = Database.insert(csShr,false);

  1. Get “userrole” using the business account (partner account )using below:
    SELECT Name, Id FROM UserRole where PortalAccountId = ‘00109000005g7wfAAA’ Or MainDealer
    outcome — this returns the role Id
  2. Get “group id” using th user role
    Select Id from group where RelatedId = ‘00E09000000YBfAEAW’ and type=’Role’ limit 1
    outcome: This returns an internal group id which salsforce maintains internally, use this outcome above in the apex sharing to define your useror groupid to share records with them.

Lastly, when in confusion open workbench utility and check for the standrd or custom Object to know for which all share Object is available.

Please note: small thing → Tasks cannot be shared with partners either using sharing sets or using Apex Managed Sharing. tasks are pretty walled off when it comes to sharing (who Id and what Id controls access)

For more info :Apex sharing 6 sharing sets https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_bulk_sharing_creating_with_apex.htm

Thanks — Mohit

Salesforce Program Architect at Salesforce