logo

NJP

Variable Validation Regex on Madrid - Steps to Implement

Import · Mar 27, 2019 · article

In Madrid there is a new functionality that will greatly reduce time and effort that we are spending on adding validations to the variables on the catalog form. The new feature is Variable Validation Regex.

In several cases we will be doing the same validations for some variables in different catalog items using client scripts ,it will obviously take some time to implement the validations to each variables even though it is already existing.

In long term it will cause maintainability issues because the number of scripts will grow with time while adding additional functionalities to form.

Using this new feature we can avoid the above cases. Now let see how to use this feature :

Create Variable Validation Regex:

  1. Navigate to
  2. Give a name for the record.
  3. In Regular Expression enter the sequence of characters that define the format of the variable value.
  4. In Validation message - enter the message that needs to be appears when the validation fails.
  5. Submit the form.

image

Using the created Variable Validation Regex in catalog form:

1.Navigate to

Testing it in catalog form:

Test your variable in the form, If you enter an invalid input it will throw the error-out the variable and shows error message, and also prevents form submission without reentering the correct input for that variable.

image

We can use a single variable validation regex in any number of variables having similar validations. It helps to reduce code,effort and saves time.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Updates:

Known issues:

1.

"If there's a mandatory variable validated by a regex, it's still possible to submit the catalog item, however, it'll get stuck on submit. If the variable isn't mandatory, it'll be validated correctly and the item can't be submitted"

Fix: no fix available ( PRB1355430)

Workarround:

Workarround for above issue(by Mark Gaghavan)

2. Unable to submit form without clearing the error message( Madrid)

Right now, if you input an invalid entry and then clear the variable, the error remains and you are forced to enter a valid entry to clear the error even if the field is not mandatory. You cannot submit unless the validation error is cleared.

Fix: I_ssue fixed in NewYork_

If this article helped you , please bookmark it or mark it as helpful.

-Satheesh

LinkedIn

View original source

https://www.servicenow.com/community/itsm-articles/variable-validation-regex-on-madrid-steps-to-implement/ta-p/2312819