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
sfdcpqsfdcpq 

Need guidence please

Requirement: When certain profile and role users select No to a picklist value, they should get an error saying not allowed

I tried below and got syntex error. Is it the correct formula?

AND
(
 ISPICKVAL( Accountable__c , "no") ,
AND
(
 $User.Id  = "00e800000014wve"
OR
(
 $User.UserRoleId  = "00E34000001pYNH",
))
Best Answer chosen by sfdcpq
VinayVinay (Salesforce Developers) 
This formula seem to be wrong, try below.
AND(ISPICKVAL( Accountable__c , "no"), OR($User.UserRoleId  = "00E34000001pYNH",$User.Id  = "00e800000014wve"))
Note. Using user id directly and hard coding is not a best practice.

Please mark as Best Answer if above information was helpful.

Thanks,

All Answers

VinayVinay (Salesforce Developers) 
This formula seem to be wrong, try below.
AND(ISPICKVAL( Accountable__c , "no"), OR($User.UserRoleId  = "00E34000001pYNH",$User.Id  = "00e800000014wve"))
Note. Using user id directly and hard coding is not a best practice.

Please mark as Best Answer if above information was helpful.

Thanks,
This was selected as the best answer
sfdcpqsfdcpq
Thank you Vinay. I tried adding contain in role but didn't work. Can you please guide ? 

AND(ISPICKVAL(  Accountable__c  , "no"), 
OR CONTAINS($User.UserRoleId   ("Service Representative", "BDR") 
,$User.Id  = "00e800000014wve"))