The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Mark Roethof
Tera Patron
Tera Patron

Hi there,

A while ago I wrote an article about the new Variable Regex Validation feature which came with Madrid. A really nice feature which simplifies the validation of Variable values. For example, for checking if a variable would contain a valid IP address, you would generally setup a Catalog Client Script with some Regex. With the Variable Regex Validation, this has become a lot easier, no coding needed anymore, no Catalog Client Script to create anymore, no script no maintain and check after upgrades anymore, etc..

Read all about it in my previous article:
Service Portal Catalog Items: Regex Field Validation [Madrid]

To help you speed up using the Variable Regex Validation, I thought, let's provide the community with some example Question Regular Expressions. The examples below, are all-in use in our environment.

Out-of-the-box available

- Number
- URL
- Zip Code

We've added

- Currency ($)
^\$[0-9]*\.[0-9]{2}$
- Currency (€)
^\€[0-9]*\.[0-9]{2}$
- Email address
^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$
- IBAN
^[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}$
- IP address
^\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b$
- Letter (A-z)
^[A-Za-z]*$
- Mac address
^[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}$
- Zip Code (NL)
^[1-9][0-9]{3}[\s]?[A-Za-z]{2}$

IBAN example:

find_real_file.png

How to add yourself

Below a screenshot of a blanc/new Question Regular Expression. You can get here thru navigating Service Catalog > Catalog Variables > Variable Validation Regex.

- Think of a name for your Variable Validation Regex, this will also be shown in the Variable Regex field on the Variable;
- What validation message should be shown to the user? For example: Input is incorrect. If adding something new here, and you have a multi-language instance, also create a UI Message for the translation (sys_ui_message);
- The actual Regular Expression, like the ones listed earlier in this article.

find_real_file.png

---

And that's it actually. Not that much to it! Hope this helps some community members a bit. If you have some interesting Regex validations or thoughts about this or even if the regex could be improved, let me know!

đź‘Ť
If this post helped you in any way, I would appreciate it if you hit bookmark or mark it as helpful.

Interested in more articles, blogs, videos, and Share Projects on Service Catalog I published?
Service Catalog


Kind regards,
Mark

---

LinkedIn

 

Comments
Yanal
Mega Guru

Hello Mark,

I have been trying to add the message in another language and it doesn't seem to work for me, any Ideas ?
I did create a message in the (sys_ui_message) table and still haven't figured out how, it's always in english

Thank you

Mark Roethof
Tera Patron
Tera Patron

Hi there,

It should work fine instantly. Can you share what you've set up? Regex + UI Message.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn
Community article list

Yanal
Mega Guru

Thank you for your reply I found the article very helpful.
I found the solution for the translating the error message, it was done by simply changing the language in the instance and adding the validation message in the other language again then submit and thats it. 
Maybe someone else will benifet from this if it doesn't work normally. 
Thanks a bunch Mark.

Mark Roethof
Tera Patron
Tera Patron

.

Alejandro4
Tera Contributor

Hello Yanal,

I had the same problem than you and I have solved it!
Please try this,

  1. Use the language picker in the header bar to switch to the desired language.
  2. Navigate to the field on the form. Service Catalog > Catalog Variables > Variable Validation Regex.
  3. Enter the error message in the target language in the Validation message field.
  4. Save

 

Regards

Sunita1
Kilo Explorer

How did to you achieved this configuration for currency, can you please share ?

Sunita1
Kilo Explorer

Hi Mark,

I am trying to set one "Question Regular Expressions" for Currency in a catalog item, and its not accepting this validation - Currency ($) : ^\$[0-9]*\.[0-9]{2}$

 

Can you please help

Shruti dhall2
Tera Contributor

Hi Mark , 

Do we have regex for IPV6 address validation ?

Version history
Last update:
‎08-10-2019 08:59 AM
Updated by: