2

I'm trying to cut down on the number of profiles in one of my Orgs. One way we're using profiles is to enforce business rules, like "Only a ZZZ user may close opportunities as won," which we do by checking the Profile ID:

<validationRules>
    <fullName>Changing_an_Opp_to_Closed_Won</fullName>
    <active>true</active>
    <description>Only the system admin and ZZZ users
                 can update the stage to closed won</description>
    <errorConditionFormula>AND(
                             AND(ISCHANGED(StageName), IsClosed=True, IsWon=True),
                             NOT(OR($User.ProfileId == '00eA0000000RhUw', 
                                    $User.ProfileId  == '00eA00000013Vro'))
                           )
    </errorConditionFormula>
    <errorMessage>You do not have the necessary access to mark an opportunity
                  &quot;Closed Won&quot; Please ask a ZZZ to do it for you.
    </errorMessage>
</validationRules>

For almost all other purposes, ZZZ users are identical to other users in their department, and I'd like to combine the profiles while making a permission set for ZZZ users. But I can't figure out what I'd do with validation rules like these. Is there a way to reference permissions/permission sets from formulas? If not, are there other approaches you've seen for this?

3 Answers 3

3

I believe such a problem can be solved at the profile level using the new custom Permissions feature and $Permission global variable that is available in Validation Rules/ VF Pages.

AND(
     AND(ISCHANGED(StageName), IsClosed=True, IsWon=True),
     NOT($Permission.nameofyourperm)
)

For more information on Custom Permissions.

https://www.salesforce.com/us/developer/docs/pages/Content/pages_variables_global_permission.htm

1
  • I just want to bring this blog to your attention if you're using Customer Permissions, Validation Rules and triggers salesfix.com.au/… Apr 27, 2016 at 10:35
4

There is an open Idea to allow the usage of Users Permission Sets in Formulas, Validation Rules and Lookup Filters.

Alternatively, you could create a Field on the User object to store the permission set name. It could be comma separated for multiple permission sets on a single user. This field would then be used in the validation rule. Source idea from j020.

-1

Found this article - hope it helps.

https://help.salesforce.com/apex/HTViewSolution?id=000221057&language=en_US

0

You must log in to answer this question.

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