Time validation regex

MaramA
Tera Contributor

HelIo,

I need to create a field in the service catalog item as "time" type,
so I tried to add regular expressions at variable Validation Regex, but it didn't work.

I used : "^([AM]{2}|[DP]{2}|[DTO]{3}|[GBL TECH]{8}|[MF]{2}|[NIS]{3}|[US TECH]{7})([0-9]{4})?$"

 
 
 
 
 
 
 
2 REPLIES 2

AdonayRocha
Tera Contributor

Hello,

Apply the following to "variable attributes" in the field with the variable type "Duration": max_unit=minutes

This will format the seconds to the minute when generating the request.

Another way is to apply a regex to the field defined as "single line text". The valid regex is "00:00:00".
Regex: ^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$

 

Documentation
Variable Attributes: https://docs.servicenow.com/en-US/bundle/washingtondc-servicenow-platform/page/product/service-catal...

AdonayRocha
Tera Contributor

Hello,

Apply the following to "variable attributes" in the field with the variable type "Duration": max_unit=minutes

Another way is to apply a regex to the field defined as "single line text". The regex validates the format "00:00:00".
Regex: ^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d$

 

Documentation
Variable Attributes: https://docs.servicenow.com/en-US/bundle/washingtondc-servicenow-platform/page/product/service-catal...