- Jace's Blog
- Posts
- Service Portal: Validating Date Format
Service Portal: Validating Date Format
Someone had asked how to do some "How to verify a date format in service portal?"
This came up in a chat I was having this week.
To use the g_user_date_format, g_user_date_time_format and getDateFromFormat(), you would have to re-include the JS file that declares these variables.
To do that go to the widget where you get a failure message and add a new dependency to a new UI script where you copy/paste the code from https://hi.service-now.com/scripts/calendar.js.
Then all your old calls ought to work as described in other posts.
// returns a date object you can test against for date/time // variables/fieldsnew Date(getDateFromFormat(newValue, g_user_date_time_format));// returns a date object you can test against for date // variables/fieldsnew Date(getDateFromFormat(newValue, g_user_date_format));
Reply