Add time limit on Expected delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2025 08:50 PM
Requirement:
Add time limit for expected delivery based on user's selection of drop-down[Delivery Type: Normal Delivery - 5 days, Express Delivery - 3 days, Express Delivery - 2 days and Express Delivery - 1 day].
In form we have below 2 variables,
1. Delivery Type[Select Box] - In this we have 4 options[Normal Delivery - 5 days, Express Delivery - 3 days, Express Delivery - 2 days and Express Delivery - 1 day].
2. Express delivery[Date/Time].
So here, when we select "Delivery Type" the "Expected delivery" field will auto-populate the date/time.
For example:
User/Me trying to submit the request on 19/06/2025 and the user/me select the "Delivery Type: Normal Delivery - 5 days", in "Expected delivery - we need to auto-populate the date/time is 25/06/2025".
Note: The Expected delivery will populate based on "Delivery Type", if it 5days,3days,2days and 1day - means we need to calculate the date - based on user's[means Singapore user's] selection from date of ticket submission, and in this we need to exclude Singapore public holidays, Saturdays and Sundays and if public holiday falls on weekends, then the following "Monday" is off day.
Thanks,
Jyothi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2025 11:02 PM
Hey Jyothi,
If you follow this approach, this wont work in year 2026.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2025 03:47 AM
client callable script include should not have initialize() method, please fix that
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
‎06-18-2025 10:36 PM
Hey Jyothi,
open cmn_schedule table in your instance to know the holiday schedule of your organisation.
In your scenario you have to create onchange client script which sends "delivery type". In script include use cmn_schedule and caluclate the time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2025 11:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2025 11:09 PM
Hey Jyothi,
Please mark it helpful if it helped you.
This code chunck will help you.
---------------------------------------------------------
var schedule = new GlideSchedule();
var scheduleLoaded = schedule.load(scheduleName);
if (!scheduleLoaded) {
gs.error('Schedule not found: ' + scheduleName); /
/ Fallback to manual calculation if schedule not found return this._calculateManuallyWithScheduleCheck(startDateStr, businessDays, scheduleName);
} /
/ Create start date/time (9 AM Singapore time)
var startDateTime = new GlideDateTime();
startDateTime.setDisplayValue(startDateStr + ' 09:00:00'); /
/ Since Singapore Holidays schedule contains only holidays,
// we need to manually add business days while checking the schedule
var currentDate = new GlideDateTime(startDateTime);
var businessDaysAdded = 0;
while (businessDaysAdded < businessDays) {
currentDate.addDaysLocalTime(1); /
/ Check if current date is a business day
if (this._isBusinessDayWithHolidaySchedule(currentDate, schedule)) {
businessDaysAdded++;
}
}
// Set delivery time to 9 AM
var resultDate = currentDate.getDisplayValue().split(' ')[0] + ' 09:00:00';
return resultDate;