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
Scenic SunriseScenic Sunrise 

Need help - Admin Profile ignored for Data Validation Requirement - how do I do this?

I've set up a number of data validation rules. I'd like to add some code that would make each of these validation rules apply to the other profiles, but not be required by the System Administrator profile.
 
Can someone explain what I need to do?
 
Thanks!
JakesterJakester
Hi Scenic,

That's a pretty easy one, fortunately. Just add an And( at the beginning of your validation, a comma at the end, and then the following:

   $Profile.Name <> "System Administrator")

For example, if the rule was

CloseDate < DATE( YEAR(TODAY()), MONTH(TODAY()), 1)

Then you'd change it to

And(
CloseDate < DATE( YEAR(TODAY()), MONTH(TODAY()), 1),
$Profile.Name <> "System Administrator")

Hope that helps!

-Jake
LdynesLdynes

Can you help me modify this validation rule? I tried the AND statement at the beginning of the rule, but then it told me I had an extra OR, and when I took that out it said I had an exra LEN...so I must be doing something wrong..thanks for any help you can offer:

 

OR(

LEN(BillingCountry) = 1,

NOT(

CONTAINS(

"AF:AX:AL:DZ:AS:AD:AO:AI:AQ:AG:AR:AM:" &

"AW:AU:AZ:BS:BH:BD:BB:BY:BE:BZ:BJ:BM:BT:BO:" &

"BA:BW:BV:BR:IO:BN:BG:BF:BI:KH:CM:CA:CV:KY:" &

"CF:TD:CL:CN:CX:CC:CO:KM:CG:CD:CK:CR:CI:HR:" &

"CU:CY:CZ:DK:DJ:DM:DO:EC:EG:SV:GQ:ER:EE:ET:FK:" &

"FO:FJ:FI:FR:GF:PF:TF:GA:GM:GE:DE:GH:GI:GR:GL:" &

"GD:GP:GU:GT:GG:GN:GW:GY:HT:HM:VA:HN:HK:HU:" &

"IS:IN:ID:IR:IQ:IE:IM:IL:IT:JM:JP:JE:JO:KZ:KE:KI:" &

"KP:KR:KW:KG:LA:LV:LB:LS:LR:LY:LI:LT:LU:MO:MK:" &

"MG:MW:MY:MV:ML:MT:MH:MQ:MR:MU:YT:MX:FM:MD:MC:" &

"MC:MN:ME:MS:MA:MZ:MM:MA:NR:NP:NL:AN:NC:NZ:NI:" &

"NE:NG:NU:NF:MP:NO:OM:PK:PW:PS:PA:PG:PY:PE:PH:" &

"PN:PL:PT:PR:QA:RE:RO:RU:RW:SH:KN:LC:PM:VC:WS:" &

"SM:ST:SA:SN:RS:SC:SL:SG:SK:SI:SB:SO:ZA:GS:ES:" &

"LK:SD:SR:SJ:SZ:SE:CH:SY:TW:TJ:TZ:TH:TL:TG:TK:" &

"TO:TT:TN:TR:TM:TC:TV:UG:UA:AE:GB:US:UM:UY:UZ:" &

"VU:VE:VN:VG:VI:WF:EH:YE:ZM:ZW",

BillingCountry )))

JakesterJakester
Sorry, I'm really busy right now-
 
2 suggestions, though:
 
  1. When sharing your code, use the SRC button - this will prevent all of the smiley faces from appearing and make it easier for folks to help you troubleshoot
  2. Start simple and work up. You're starting with a really complex rule, so there are lots of places where you could be having trouble. Make sure you can get something simple working, then gradually add in the complexity.

Good luck!

Steve :-/Steve :-/

Here you go:

 

AND ( 
NOT( $Profile.Name = "System Administrator"), 
BillingCountry = "CA", 
OR( 
LEN(BillingState) <> 2, 
NOT( 
CONTAINS("AB:BC:MB:NB:NL:NS:NT:NU:ON:PE:QC:SK:YT", BillingState) 
)))

 

AND ( 
NOT( $Profile.Name = "System Administrator"), 
BillingCountry = "US", 
OR( 
LEN(BillingState) <> 2, 
NOT( 
CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" & 
"IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" & 
"NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" & 
"WA:WV:WI:WY:PR", BillingState) 
)))

 

AND ( 
NOT( $Profile.Name = "System Administrator"), 
OR( 
LEN(BillingCountry) <> 2, 
NOT( 
CONTAINS( 
"AD:AE:AF:AG:AI:AL:AM:AN:AO:AQ:AR:AS:AT:AU:AW:AX:AZ:BA:BB:BD:BE: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