With the field in place, we can set up the rule which will define the sharing.
From the app launcher, open the FormulaShare app (if you don't see this, check that the permission set is assigned).
Rules are created from the FormulaShare Rules tab. Click "New Rule" to start setting one up.
The options below are set in this screen:
- Label, API Name and Description: Add something to distinguish this rule from others
- Object to Share: Select the object from the list of those available to share. Objects included are those which:
- Support sharing - child objects in a master-detail relationship and some standard objects do not support independent sharing rules
- Have an internal or external organisation-wide default sharing setting of either Private (for Read or Edit access levels) or Public Read Only (for Edit access level)
- Location of field with user, role or group: Objects can be shared based on values in fields on either the object itself (these rules are known as Standard Rules), or an object or custom metadata type related through a series of lookup or master-detail fields (these rules are called Cross-Object Rules). Limits apply to the total number of active rules of each kind
- Share With: The type of entity this rule should share with. Options for FormulaShare Lite are "Users", "Roles", "Roles and Internal Subordinates", "Roles, Internal and Portal Subordinates" (includes both community and portal users) and "Public Groups". FormulaShare Enterprise and Unlimited also include options to share with Manager Groups or users' Account or Opportunity Default Teams
- Specified in Field: The field which contains a reference to the user, role or group needing access. Fields which can be chosen are text fields, formula fields returning text and or lookups to the user object. The field selected should be populated with either the Salesforce 15 or 18 character id of the user role or group, or the role or group name (developer name) for sharing to work correctly
- Containing Type: Choose either "Id" or "Name" depending on which of these are populated in the field selected
- Access Level: Set to Read or Edit. For objects with an organisation-wide default sharing setting of Public Read Only, only the Edit option will be available
- Sharing Reason: Available for custom objects only. A unique sharing reason must be used for each rule, and the name of the sharing reason must be unique across all rules (including those for other objects). To set up a new reason, click the Manage Apex Sharing Reasons link below the field - clicking the refresh icon after setting this will show the reason to be selected
Clicking Save on this screen deploys details of the rule to be set up as custom metadata in the FormulaShare Rules custom metadata type. See the accessing and deploying rule metadata section for details of this.