I am trying to configure a validation rule in my screen flow for the input of the address component. This consists of the Mailing Street, City, State, and Country. There is no "required" field to click on this component, so I am hoping to use a validation rule to make sure that all necessary fields are filled. Initially I had it set to check that all of the above fields were not blank, but in my testing I remembered that some countries do not have states. I have the list of countries with states, and I'm hoping to make a validation rule that considers the following:
If the country is one with states, then validate that all address fields are filled in. Else if the country is one without states, make sure that all fields except state are filled in.
I am struggling to put the if, else statement in my head into a validation rule for the flow.
Also, validation rules in flow are different than fields within Salesforce, as the statement should return true if valid.
Steven Trumble (Strum Consulting) Forum Ambassador
Sure, try this.
Start with all the fields that should not be blank - street, city, country.
Then you hvae two conditions. Either there is a Country with states (province), then state should have a value. or a country without states, then you don't need a value.
AND(
NOT(ISBLANK({!Address.street})),
NOT(ISBLANK({!Address.city})),
NOT(ISBLANK({!Address.country})),
OR(
AND(
ISBLANK({!Address.province}),
CASE({!Address.country},
"Australia", 1,
"United States", 1,
"Mexico", 1,
0
) = 0
),
AND(
NOT(ISBLANK({!Address.province})),
CASE({!Address.country},
"Australia", 1,
"United States", 1,
"Mexico", 1,
0
) = 1
)
)
)