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
Kailey ConnatserKailey Connatser 

Validation Rule that Includes Multiple Profiles

Good day,

We have a validation rule set up that does not allow a picklist field to go "backwards", and it only allows the system administrator profile to change the field. I would like to add another profile to the rule that can move the field "backwards" as well.

I added the second profile ID to the code, and it is giving me this error: Error: Syntax error. Missing ')'
What am I doing wrong?
 
IF (NOT ( ISPICKVAL(StageName__c, "Closed Lost")),
(
CASE(StageName__c , 
"Activity",1, 
"Application",2, 
"Decision",3, 
"Final",4, 
"Closed Lost",1,0) 
< 
CASE(PRIORVALUE(StageName__c) , 
"Activity",1, 
"Application",2, 
"Decision",3, 
"Final",4, 
"Closed Lost",1,0)
),False)
&& (NOT($User.ProfileId="00eE0000000v6Qq",$User.ProfileId="00eE0000000Nw8V"))

 
Amit Chaudhary 8Amit Chaudhary 8
Please try belo formula
IF ( AND( NOT ( ISPICKVAL(StageName__c, "Closed Lost")) ,  (NOT($User.ProfileId="00eE0000000v6Qq",$User.ProfileId="00eE0000000Nw8V")) ),
		(
		CASE(StageName__c , 
		"Activity",1, 
		"Application",2, 
		"Decision",3, 
		"Final",4, 
		"Closed Lost",1,0) 
		< 
		CASE(PRIORVALUE(StageName__c) , 
		"Activity",1, 
		"Application",2, 
		"Decision",3, 
		"Final",4, 
		"Closed Lost",1,0)
		),
		False)

Let us know if this will help you
Swaraj Behera 7Swaraj Behera 7
Can you use this code
 
IF (NOT ( ISPICKVAL(StageName__c, "Closed Lost")),
(
CASE(StageName__c , 
"Activity",1, 
"Application",2, 
"Decision",3, 
"Final",4, 
"Closed Lost",1,0) 
< 
CASE(PRIORVALUE(StageName__c) , 
"Activity",1, 
"Application",2, 
"Decision",3, 
"Final",4, 
"Closed Lost",1,0)
),False)
AND ((NOT($User.ProfileId="00eE0000000v6Qq",$User.ProfileId="00eE0000000Nw8V")))

 
Kailey ConnatserKailey Connatser
Neither of these worked - it still gave me the same syntax error.
Deepak RathinaveluDeepak Rathinavelu
Hi Kailey,

Your condition is fine, just the profile part which needs tweaking a bit.

try this out 
(NOT(OR($User.ProfileId="00eE0000000v6Qq",$User.ProfileId="00eE0000000Nw8V")))

NOT() function accepts only one condition, try putting them in an OR() function.

Hope it helps.

Regards,
Deepak Rathinavelu