- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 09:18 PM
Hi @Thomas99
try the code in On Change client script ,
(function () {
var currentDate = new GlideDate();
var targetStartDate = new GlideDate();
var businessDaysToAdd = 2; // Number of business days to add
while (businessDaysToAdd > 0) {
// Move the target date one day ahead
targetStartDate.addDays(1);
// Check if the target date is a business day (Monday to Friday)
if (isBusinessDay(targetStartDate)) {
businessDaysToAdd--;
}
}g_form.setValue('your_start_date_field', targetStartDate);
// Function to check if a given date is a business day (Monday to Friday)
function isBusinessDay(date) {
var dayOfWeek = new GlideDateTime(date).getDayOfWeek();
return dayOfWeek >= 2 && dayOfWeek <= 6;
}
})();
// Replace 'your_start_date_field' with the actual field name on your form that represents the start date.
//Please mark helpful if its worked.