0

I have a formula field set up to read the String/Text value of a Formula field on a record for the comparison in a Restriction Rule.

When I enable the rule and access a record that should be accessible by a User that meets the user qualification of the Restriction rule, I get this error on the record page and in a flow that attempts to access the same record:

Looks like there's a problem.

Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details. ui.services.connection.api.PartnerConnectionException: UNKNOWN_EXCEPTION: An unexpected error occurred.

For what it's worth, here's the XML of the restriction rule:

<?xml version="1.0" encoding="UTF-8"?>
<RestrictionRule xmlns="http://soap.sforce.com/2006/04/metadata">
    <active>true</active>
    <description>Users with the MHC View Only New Cases permission will be restricted to viewing cases with status &amp;quot;New Case&amp;quot;, even if they own them.</description>
    <enforcementType>Restrict</enforcementType>
    <masterLabel>MHC View Only New Cases</masterLabel>
    <recordFilter>Status_Text__c=&apos;New Case&apos;</recordFilter>
    <targetEntity>HR_Case__c</targetEntity>
    <userCriteria>$Permission.MHC_View_Only_New_Cases=true</userCriteria>
    <version>1</version>
</RestrictionRule>
2
  • doesn't userCriteria have to reference a property of the running user via $User.xxx ? I realize $Permission is a property of the running user but maybe the beta doesn't yet support that? Could you create a checkbox formula field on User that was $Permission.xxx and ref that field in userCriteria ?
    – cropredy
    Commented Dec 9, 2021 at 1:32
  • Maybe...? that doesn't seem to be the issue, since I get the error only on the accounts I'm expecting. I'll try that and some variations and get back Commented Dec 9, 2021 at 15:12

1 Answer 1

1

Restriction rules cannot be used with Formula fields, as of the Winter '22 release. Not only is it pretty plainly written on this document -- which is not the easiest thing to find -- but I also tested it myself and received the above error. My suspicion is that Salesforce has yet to properly restrict the fields available for selection to exclude formula fields.

In light of this constraint, my workaround was to create another custom field on the object (a text field in my case), and have a record-triggered (before update, not that it matters) lightning flow to copy the picklist value out of the picklist into the new field. Then, the restriction rule can be compared against the new, standard text field.

What this means for now: Fancy formulas that rely on $User, $Permission, and other context-specific values are a no-go, since persisting those values in the way that I've described would be bad.

1
  • 1
    the old cross-object formula field restriction for RSF field workaround!
    – cropredy
    Commented Dec 9, 2021 at 19:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .