In date/time variable,should be selected in PST time zone and should not allow past dates selection
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 08:15 PM
Hi @Ankur Bawiskar @Maik Skoddow @Mohith Devatte @SwarnadeepNandy @SANDEEP28
My requirement is,In date/time variable,date should be selected in PST time zone and should not allow users to select past dates.
i have already an existing client script which makes users not to select PST time zone.Here is the screenshot below
Please help me on my requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 08:34 PM
to restrict past date you can compare the time
please share the script here and not the screenshot.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 11:01 PM
please find the script which i have using not to select past dates.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2023 11:12 PM
update as this
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var currentDate = new Date().getTime();
var refreshDate = new Date(g_form.getValue('start_date')).getTime();
if (refreshDate < currentDate) {
var message = 'Date shuold be in Future Date';
g_form.showErrorBox('start_date', message);
g_form.clearValue('start_date');
// g_form.showFieldMsg('revised_refresh_date', "Date Should not a Past Date", 'error');
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2023 07:07 PM
tried with the above script provided by you, not working, Any suggestions why this was not working.