+ Start a Discussion
Ellsa JamesEllsa James 

Can someone please advise on the syntax for the below formula?

I am trying to create a validation rule that will prevent users from closing a record with a certain status. Only 2 users should be able to close the records with these statuses.

Object = Custom object called Application for stock
Criteria for the rule = If Type of Request= "Placement", "Demo" or "Consignment" And Status = Closed And user id = "005200000036LQs" OR "00520000003RRW6".

Type of request andstatus are picklist fields.

Current formula

(ISPICKVAL(Type_of_Request__c, "Placement") || 
(ISPICKVAL(Type_of_Request__c, "Demo")|| 
(ISPICKVAL(Type_of_Request__c, "Consignment ")))) 

&& 

ISPICKVAL( Status__c , "Closed") 

&& 

$User.Id <> "005200000036LQs" || $User.Id <> "00520000003RRW6"

At the moment the rule fires on every edit.

 
Best Answer chosen by Ellsa James
ShashankShashank (Salesforce Developers) 
There should be an "AND" between the user names. There are a few syntax issues as well with the brackets. Please see if this works:

(
(ISPICKVAL(Type_of_Request__c, "Placement")) || 
(ISPICKVAL(Type_of_Request__c, "Demo"))|| 
(ISPICKVAL(Type_of_Request__c, "Consignment "))
)

&& 

ISPICKVAL( Status__c , "Closed") 

&& 

($User.Id <> "005200000036LQs" && $User.Id <> "00520000003RRW6")