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
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:
- Organization wide access (baseline line)
- Expand data access vertically using Roles hierarchy
- Expand across using sharing Rules
- Manual Sharing
- 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.
- 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.
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.
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);
- 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
- 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
Help | Training | Salesforce
salesforce help; salesforce training; salesforce support
Thanks — Mohit