Accurate information and reports are vital in an effective Salesforce CRM system and without it, users and sales management cannot make informed decisions. One way to achieve accurate information for reporting is by ensuring that data is stored in a consistent manner.
In this recipe, we will create a validation rule to ensure that UK postcodes conform to the correct format.
Carry out the following step to create a validation rule:
Valid UK Postcode
in the Field Label textbox (upon clicking out of the text box, the name changes to Valid_UK_Postcode).This validation rule is for ensuring the entry of valid UK Postcodes
.AND( NOT( OR( REGEX( BillingPostalCode, "[a-zA-Z]\d\s\d[a-zA-Z]{2}"), REGEX( BillingPostalCode, "[a-zA-Z]\d\d\s\d[a-zA-Z]{2}"), REGEX( BillingPostalCode, "[a-zA-Z]{2}\d\s\d[a-zA-Z]{2}"), REGEX( BillingPostalCode, "[a-zA-Z]{2}\d\d\s\d[a-zA-Z]{2}"), REGEX( BillingPostalCode, "[a-zA-Z]{2}\d[a-zA-Z]\s\d[a-zA-Z]{2}"), REGEX( BillingPostalCode, "[a-zA-Z]\d[a-zA-Z]\s\d[a-zA-Z]{2}") ) ), OR( UPPER( BillingCountry ) = "UK", UPPER( BillingCountry ) = "U.K.", UPPER( BillingCountry ) = "UNITED KINGDOM" ) )
Please enter a valid UK Post code of the typical format: XXNN NYY
.18.189.189.67