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.


N52 Formula Manager Solution

The Formula Manager 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


N52 Formula Manager 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


   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. 


Did you know?

There are a number of different ways North52 business rules can be used in Dynamics 365

These include:

  • Via API from another application. This allows a customized application to separate its rules so that they can be maintained outside of custom code.
  • In processes that loop over a collection of records - on Schedule or in real-time.
  • As a step in a Workflow, Custom Action, Business Process Flow or a Power Automate Flow.
  • Making forms more interactive. Visibility, validation, real time data updating is all provided by the North52 rule engine.
  • Security functions to restrict or open access to records.
  • ...and many more!

Learn more about North52 Business Process Activities