How to Set Date after 3 Business days

Santhosh23
Tera Expert

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

2 REPLIES 2

chetanb
Tera Guru

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

jubael
Tera Contributor

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.

jubael_0-1741994805485.png



Can scripts fit in there?