I have the following validation rules that should validate whether an Account has a 'complete' address when an opportunity is created for the account, and they're not validating and I'm not sure why. I have them listed under validation rules for opportunities.
Validation rule 1:
AND(
ISPICKVAL(StageName, "Award Close 100%"),
(LEN( Account.Street_Address__c )=0),
(LEN( Account.City__c )=0))
Validation rule 2:
AND(
ISPICKVAL(Account.Country_Code__c, "United States"),
OR(
LEN( Account.State_Province__c ) < 2,
NOT(
CONTAINS("AL:AK:AS:AZ:AR:CA:CO:CT:DE:DC:FL:FM:GA:GU:HI:ID:" &
"IL:IN:IA:KS:KY:LA:ME:MH:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" &
"NJ:NM:NY:NC:ND:MP:OH:OK:OR:PW:PA:PR:RI:SC:SD:TN:TX:UT:VT:VA:" &
"VI:WA:WV:WI:WY:AE:AA:AP", Account.State_Province__c )
)))
We have old data in our system where some accounts don't have full addresses and we wanted to make sure the account stays up to date.
before insert
/before update
trigger. – Adrian Larson♦ Apr 22 '15 at 21:14account.country_code__c
is being tested for "United States" and not "US" ? When faced with these issues, I break down the validation rule into simpler bits (comment out clauses) and make sure each condition is working as expected; making adjustments as needed – cropredy Apr 23 '15 at 1:26