How to Set Date after 3 Business days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 10:41 PM
How to Set Date after 3 Business days - For Example Today is Thursday user should not be able to choose Friday, Saturday, Sunday, Monday and Tuesday. Its should exclude saturday and sunday while checking 3 days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2024 10:56 PM
Hello @Santhosh23 ,
Can you try with onchange client script as-
function onChange(control, oldValue, newValue) {
if (control.id == 'YOUR_DATE_field_id') {
// Parse the new date value
var newDate = gs.dateUtil.parseDate(newValue);
// current day of the week
var currentDayOfWeek = newDate.getDay();
// target date by adding 3 business days
var targetDate = gs.dateUtil.addBusinessDays(newDate, 3);
// To check if the new date is before the target date or coming on a weekend
if (newDate < targetDate || [0, 6].includes(currentDayOfWeek)) {
// Set the value back to the old value and show an error message
control.setValue(oldValue);
gs.error('Please select a date at least 3 business days from now, excluding weekends.');
}
}
}
if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,
CB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2025 04:26 PM
Where does that Util come from?
Can I do something like this to get a due date of [[travel_end_date]] + 3 business days? Say I create a task and I send in the end date. You say UI policy, but I'm trying to set this from the workflow builder.
Can scripts fit in there?