0

I am trying to create a validation rule to prevent users that aren't associated with the user Id profiles from changing a "New" Lead Status to any other status

When I check the syntax for the below, it says The there is a ')' missing somewhere

AND(  
    ISCHANGED(Status), 
    ISPICKVAL(PRIORVALUE(Status),"New"), 
    ISPICKVAL(Status, "Working"),
    ISPICKVAL(Status, "MQL"),
    ISPICKVAL(Status, "Unqualified"),
    ISPICKVAL(Status, "Sales Qualified"),
    ISPICKVAL(Status, "Decision Maker"),
    ISPICKVAL(Status, "Won"),
    ISPICKVAL(Status, "Lost"),
    $User.ProfileId <>"0e2M000001yVtl",
    $User.ProfileId <>"00e41000001XST2",

)
3
  • Do not use hard-coded Ids. Much better to filter on $User.Profile.Name.
    – Adrian Larson
    Commented Dec 19, 2018 at 19:02
  • Or on $Permission.
    – David Reed
    Commented Dec 19, 2018 at 19:03
  • Checking what the value changes to is a bit redundant unless you only want to prevent changes to certain values.
    – Adrian Larson
    Commented Dec 19, 2018 at 19:06

1 Answer 1

0

You have an extra comma at the end.

Also, you're going to need to mix AND and OR; this rule cannot currently fire.

AND(  
    ISCHANGED(Status), 
    ISPICKVAL(PRIORVALUE(Status),"New"), 
    OR(
        ISPICKVAL(Status, "Working"),
        ISPICKVAL(Status, "MQL"),
        ISPICKVAL(Status, "Unqualified"),
        ISPICKVAL(Status, "Sales Qualified"),
        ISPICKVAL(Status, "Decision Maker"),
        ISPICKVAL(Status, "Won"),
        ISPICKVAL(Status, "Lost")
    ),
    $User.ProfileId <>"0e2M000001yVtl",
    $User.ProfileId <>"00e41000001XST2"
)

From a practical standpoint, you can also simply say:

AND(  
    ISCHANGED(Status), 
    ISPICKVAL(PRIORVALUE(Status),"New"), 
    $User.ProfileId <>"0e2M000001yVtl",
    $User.ProfileId <>"00e41000001XST2"
)

This fits the semantics better; if it changes from New to ANY other value, even values you don't have yet, this rule will prevent the edit.


Finally, consider using profile names, instead:

AND(  
    ISCHANGED(Status), 
    ISPICKVAL(PRIORVALUE(Status),"New"), 
    $User.Profile.Name <> "Name 1",
    $User.Profile.Name <>"Name 2"
)

You must log in to answer this question.

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