Scenario Overview
In this scenario we need to validate that the user enters exactly four digits for a credit card field or leaves it blank. The validation needs to execute when the user tabs out of the credit card field (i.e. Client-Side) and it also needs to execute on Save (i.e. Server-Side.)
One thing that makes this validation tricky is that the field storing the credit card data was setup as a string field so we can't rely on the CRM validation for whole numbers.
Below is an example of the message the user would see when tabbing out of the Credit Card 4 Digits field with an invalid last 4 digits.
North52 Decision Suite Solution
The North52 Decision Suite solution works like this,
- A Client Side & Server-Side validation rule is created to enforce data quality
- If data is in the field it will perform a check otherwise it will pass
- The value in the credit card field is checked with a Regular Expression
- If it does not contain exactly 4 digits it will fail the validation test and display an error message to the user
North52 Decision Suite Steps
The following set of steps outline how to create this Formula
- Create a new formula of type 'Validation'
- Set the Source Entity to 'Contact'
- Set the Mode to 'Client Side & Server-Side'
- Set the Source Property to 'Credit Card 4 Digits' under the server-side properties
- Holding down the control key also select the 'Credit Card 4 Digits' under the Contact form
- Copy & paste the formula below into the formula
- Click save & test
Formula
if(ContainsData([contact.new_creditcardfourdigits]),
if( RegexIsMatch([contact.new_creditcardfourdigits] , «^[0-9]{4}$») , 'NoOp' ,
'You must enter exactly 4 digits in the Credit Card 4 Digits Field')
, 'NoOp')
Wizard - ContainsData
Please see below the wizard you can use to create the ContainsData() function call used in this formula.