function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
matthew Gordonmatthew Gordon 

Case Status validation rule

Hi All, 

I am trying to create a validation rule that restricts the ability to change the status of a case to Transfer for all users. 
It should restrict the user from changing the status of a case with a specific record type to transfer, unless the user has a specific role which will allow it to use that status.

The syntax passes, but whenever I test the rule on a case I get the validation error with the roles listed.

Any help would be very appreciated. 

Thank you in advance!
 
AND( 
ISPICKVAL(Status, "Transfer"), 
RecordType.Name = "Example", 
OR( 
NOT($UserRole.Name = "CEO"), 
NOT($UserRole.Name = "CFO"), 
NOT($UserRole.Name = "CIO"), 
NOT($UserRole.Name = "Admin") 
) 
)

 
Doug Beltowski XDoug Beltowski X
Try changing your OR to AND.

The OR statement looks for the first item that is true and then quits.  So if the User's role is not CEO then it will return true.  You want it to return true of none of the Roles match, so AND would be appropriate.
Parker EdelmannParker Edelmann
Doug Beltowski is correct, but I would add one more thing,
AND(ISPICKVAL(Status, "Transfer"), 
ISCHANGED(Status),
RecordType.Name = "Example", 
OR( 
NOT($UserRole.Name = "CEO"), 
NOT($UserRole.Name = "CFO"), 
NOT($UserRole.Name = "CIO"), 
NOT($UserRole.Name = "Admin") 
) 
)
Parker EdelmannParker Edelmann
I don't know how those tags got in there, and I goofed up a little on writing it so let me give a correct one.
 
AND(ISPICKVAL(Status, "Transfer"),
ISCHANGED(Status),
RecordType.Name = "Example",
AND(
NOT($UserRole.Name = "CEO"),
NOT($UserRole.Name = "CFO"),
NOT($UserRole.Name = "CIO"),
NOT($UserRole.Name = "Admin")
)
)
Sorry about that, I missed "AND" and put "OR" in the last formula..
Thanks,
Parker