With custom metadata rules, FormulaShare allows you to specify the users, roles and groups which require access on fields on a custom metadata record.
In order to determine which custom metadata record applies, FormulaShare lets you configure the relationship between custom objects and the custom metadata type by selecting which fields on each should match. The sharing itself can then be based on the contents of the field on the custom metadata type.
For example, let's say Account records in our org have their division defined by a custom Division picklist:
To control sharing, we can use a custom metadata type which includes custom fields with names of any public groups and roles which require access:
Notice that in this case, the values in the Label field of the custom metadata type match the picklist values in our Division picklist. FormulaShare gives flexibility to match records based on the name, label or any custom field from the custom metadata type.
Now with the data model set up, we can create a FormulaShare rule which shares each account record to the Sales Team on the relevant Division custom metadata record. Select the "Related Object or Custom Metadata Type" option when creating the rule, and expand the options to select Custom Metadata:
We can now select the appropriate custom metadata type ("Division"):
We've also selected the fields which match this custom metadata type to records in the Account object. In our case, this is "Label" from the custom metadata type, and the "Division" picklist from the Account. If you're not sure which fields match, use the Browse option to see a sample of existing data.
Once this is confirmed, we can select the field from the custom metadata type which specifies the group to receive access - "Specified in Field" in the screenshot below:
And that's pretty much it! This rule will provide access to the Sales Team public group for all account records where there is a match between the custom metadata record label and the Division picklist on the Account.
This is a pretty simple rule, but all the usual options still apply here to get creative with how sharing is defined. We can traverse relationships to share based on custom metadata record matches from related objects, and the match field can itself be a formula field to allow for sharing which is conditional based on other context from the record.