Creating a field to control sharing

We know what we want to share, right? Great!

FormulaShare can share any standard or custom object which supports sharing - essentially any objects which have an org-wide default sharing of either Private or Public Read Only.

For FormulaShare to know who should get access, we need a field somewhere with the name or record id of the entity needing access:

This field can be a text field, a formula field or, in the case of user sharing, a lookup.

Where does this field need to be? There are some options!

  • On the record to be shared
  • On a related record (FormulaShare can traverse up, down and across multiple relationships when needed)
  • On a custom metadata record

Rules with the field is on the record to be shared are known as standard rules. Rules where the field is on a related object or custom metadata type are known as cross-object rules.

A Simple Example

A common scenario where FormulaShare comes in useful is sharing to entities in formula fields on the object to be shared. With this approach, it's possible to reference fields from parent objects, grandparent objects and higher (Salesforce supports up to 5 levels of parent in a formula field). Complex conditional logic can also be defined in the formula field if needed.

In the screenshot below, we’re setting up a field on Donation which holds the name of the Finance Manager Role (a text field on the Country object, which is a grandparent of Donation):

Donation Formula Field


We can see the field populating below:

Poplated Formula Field


If sharing to a role or public group created in your org, the exact Role Name or Group Name should be populated in this field. These names are found in the Roles or Public Groups areas of the the setup menu. The record id of a role or group can also be used as an alternative to its name if this is preferred.

For sharing to a particular user, the field must be populated with the record id of the person's user record.

Note: It's also possible to share to the standard groups provided in the org by default. For example, to share to "All Internal Users" a group name of AllInternalUsers can be used (other standard group names can be found by querying the Group object).