Restrict the submission of Normal and Standard change requests with a past date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 03:07 AM
Hello Team,
We have requirement "Restrict the submission of Normal and Standard change requests with a past date"
I have created below script but it's not working. Please help me on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 04:32 AM
Thank you, Ankur this is working, but I need to allow todays and future, how can I do that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 03:58 AM
Hi @sattimsetti ,
Use below script, i have tested it in my PDI, working fine.
function onSubmit() {
var changeType = g_form.getValue('type');
var requestedStartDate = g_form.getValue('start_date');
var todayDate = new Date();
var format = g_user_date_time_format;
if ((changeType == 'normal' || changeType == 'standard') && requestedStartDate) {
var startDateMs = getDateFromFormat(requestedStartDate, format);
var todatDateMs = getDateFromFormat(todayDate, format);
if (startDateMs > todatDateMs) {
g_form.showFieldMsg('start_date', 'The requested start date cannot be in the past date.', 'error');
return false;
}
}
}
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 04:15 AM
Hello Runjay Patel,
Thank you for response !!
When I select past date and future also getting an error.
Thanks,
Raju