Service Portal: No validators for IP, Email, Duration, and URL type variables.
Steps to Reproduce
Create a catalog item with the following types of variables:
For more information, see the product documentation topic Create a service catalog variable.
Launch the Service Portal instance and navigate to the newly created catalog item.
Try to give incorrect values to the newly created types of variables and observe the result.
Expected behavior: The validators should be fired indicating the user that the entered value is incorrect with the help of some alert or messages.
Actual behavior: No validators given for these variable types in Service Portal.
Use onChange catalog client scripts to validate the input. You can use either a simple script when only a few variables need to be validated or a more robust and centralized approach for a larger installation.
The following example demonstrates this approach for an Email variable. The script uses a regular expression to validate the email address, and displays a notification if the user inputs an invalid value. This sample script can be applied to the other variable types by using different regular expressions that are applicable to that type.
Larger implementations necessitate a more robust and centralized approach. You can define the validation function in a script include and abstract it to handle all four of the affected variable types, as shown in the following example.
Client scripts can be simplified to call the same function via GlideAjax. If you need assistance with creating the regular expressions for the other variable types, consider searching online for a regex generator site to make them for you.
Related Problem: PRB957575