0

Disclaimer: I am rather new to Validation Rules (and Salesforce in general) and GREATLY appreciate any assistance this community could offer

I am attempting to lock down 3 picklist items from the Account Type picklist so that only 4 specific users can select these values using Validation Rules.

In the past, I was able to accomplish something similar in Opportunity using Validation Rules, but the need only called for the restriction of 1 value. I'm having issues with migrating this syntax to handle multiple values.

Here is my current syntax that isn't working:

AND( 
$User.Id <> "0051N000005giDN", 
$User.Id <> "0051N00000696tX", 
$User.Id <> "0051N000005gi5T", 
$User.Id <> "0051N000005EMyk", 
ISPICKVAL(Type,("Partner", "Partner Customer", "Direct Customer")))
  • as Jayant says below - using Custom Permissions is the right answer here – cropredy Mar 1 at 2:51
1

ISPICKVAL(picklist_field, text_literal) can only compare the field's value to a single text literal.

You will need to change your formula as:

AND( 
...

    OR(
        ISPICKVAL(Type,"Partner"),
        ISPICKVAL(Type, "Partner Customer"),
        ISPICKVAL(Type, "Direct Customer")
    )
)

On a side note, instead of using User Ids in there, you can assign a custom permission to such Users and then utilize that in your formula.

  • I've been looking into using Custom Permissions and yes, I agree that this is the way to go. I am having difficulties using the custom permission in the validation rule: ` AND( NOT ($Permission.Can_Set_Account_Type) OR( ISPICKVAL(Type,"Partner"), ISPICKVAL(Type, "Partner Customer"), ISPICKVAL(Type, "Direct Customer") ) ) ` – Tom Casillas Mar 1 at 16:14
  • @TomCasillas if you have specific issues with Custom Permissions, you may like to open a new question. With this question, your original issue should have been resolved as you were not using ISPICKVAL correctly. Here at SFSE, we try to keep questions specific to a problem. – Jayant Das Mar 1 at 16:36
0

Hard coding ID's like this is not a best practice. An alternative would be to identify these users another way like by profile, custom permission, etc.

If you absolutely must use the ID's, try using the 18 digit ID.

Also, since you want it to be any of these 4 users you'd need an OR statement in there too. Try something like this:

AND(
OR($User.Id <> user1id, 
$User.Id <> user2id, 
$User.Id <> user3id, 
$User.Id <> user4id), 
ISPICKVAL(Type,("Partner", "Partner Customer", "Direct Customer")))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.