Service Portal: Validating Date Format
So a few weeks ago someone had asked how to do some "How to validate a date format in service portal?"
So this came up in a chat I was having this week.
To use the
getDateFromFormat(), you would have to re-include the JS file that
declares these things.
To do that goto 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
new Date(getDateFromFormat(newValue, g_user_date_time_format));
// returns a date object you can test against for date
new Date(getDateFromFormat(newValue, g_user_date_format));