Custom Data Restrictions in Customer Voice

Add Restrictions

When you add a question which requires a text-based response in Customer Voice, it is possible to add restrictions to what type of text they can respond with. You can restrict their answers to be a number, an email address, or a string in a predefined format (based on a specific regular expression also knows as RegEx) such as a passport number.

You can add restrictions to a text-based question by selecting the ellipsis (…) on the bottom right of the question. Select restrictions. Then select the restriction type.

AddCustomRest.png

Email

emailvalidation.png

Number

Custom

What I like about the custom restrictions apart from the awesome flexibility in what you can restrict or allow. It also allows you to customise the error message to explain what the correct format is. I won’t try to pretend I know how to write regex from scratch but this is a lot of googling, tweaking, trial and error. I learn best from examples but a few basics of regular expressions here:

[A-Za-z] all letters (uppercase and lowercase)

[^0-9] all non-digit characters

[0-9] all digits

^ Start of string or start of line (unless [^inside brackets], it means "not")

$ End of string or end of line

Set the restriction type to ‘Custom’ - this will unveil a section for your RegEx code and also a section for your customised message to guide the user to the desired format.

CustomFormattingConfig.png

Dates

There is the option for a ‘Date’ type question response, however it forces the use of a date pickers which can be cumbersome for selecting dates which are a long time in the past e.g. date of birth or a long time in the future e.g. passport expiry date. Allowing the user to safely enter a string in a predefined format is a better option.

dd/mm/yyyy or dd/mm/yy formatted date

dd/mm/yyyy or dd/mm/yy formatted date

^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[13-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$ |^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$ |^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
mm/yyyy formatted date

mm/yyyy formatted date

^(0[1-9]|1[0-2])\/?([0-9]{4}|[0-9]{2})$

Phone Numbers

Obviously this varies hugely by region and also the preference if you want to customer to enter the country code also e.g. +61 but here are a few examples of some Australian phone number regex

Australian mobile number

^\s*(0[4|5]{1})(\d{2})[ ]*(\d{3})[ ]*(\d{3})\s*$
mobile number validation.png

Australian landline phone number

^\s*(0[2|3|7|8]{1})(\d{2})[ ]*(\d{3})[ ]*(\d{3})\s*$
PhoneNumber.png

Australian mobile number or landline phone number - you can combine multiple expressions with an ‘or’ statement as below to allow either a mobile or landline phone number in a single answer

^\s*(0[2|3|7|8|4|5]{1})(\d{2})[ ]*(\d{3})[ ]*(\d{3})\s*$
AnyPhoneNumber.png

Email addresses

Comma separated email addresses

^([\w+-.%]+@[\w-.]+\.[A-Za-z]{2,4},?)+$
Multipleemailsvalidation.png

Personal Identification

It is really important that this data is answered correctly and in full so this is where the custom restrictions get really important. These can also be very regional but here are a few standard Australian examples that you could perhaps use and tweak to your specific format

Medicare number - 10 digits only

^\b[0-9]{10}\b$
Medicare number - 10 digits only

Medicare position on card or IRN number - Single digit

^\b[0-9]{1}\b$
SingleDigit2.png

CRN pension number - 9 digits long followed by a single letter e.g. 123456789A.

^([A-Z]{2})([0-9]{6})([A-Z]{1})$
Pension CRN2.png

DVA pension number - 2 letters, 6 numbers, 1 letter e.g. NX213837A

^([0-9]{9})([A-Z]{1})$
PensionDVA2.png

Any Australian pension number - again combining the expressions as below to allow either the DVA or the CRN number in a single answer

^([A-Z]{2})([0-9]{6})([A-Z]{1})$|^([0-9]{9})([A-Z]{1})$
AussiePensionNumber.png

Residential referral code - begins with 1- followed by a series of numbers e.g. 1-2833837362

^1-[0-9]*$
RespiteNumber.png

I hope this has inspired you to get a little more snazzy with your customer voice surveys. I know these expressions won’t be as helpful to our non-Australian friends but maybe you can tweak the ones here or there are heaps of resources out there which can help you as RegEx has been around since the year 1951

Questions, comments etc. always welcome ☺

Previous
Previous

Make the Activity Timeline Control Useful in Model-Driven Power Apps

Next
Next

Digitising paper-based application forms with Customer Voice - it’s not just a survey tool!