We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Workflow timer add businessdays

Swati k1
Tera Contributor

Hi All,

 

We are using below workflow timer to wait 10 days from start date  , now client asking to change 10 Business days , kindly help me code 

 

 

var change = current.variables.start_date;
var gdt = new GlideDateTime(change);
gdt.addDays(-10);
var assignment = gdt.getDate();
var todaydate = new GlideDateTime();
todaydate = todaydate.getDate();
var dur = new GlideDuration();
dur = GlideDateTime.subtract(todaydate, assignment);
var gdt2 = new GlideDateTime(dur.getValue());
var diff = gdt2.getNumericValue();
diff = diff/1000;
if (diff > 0) {
answer = diff;
} else {
answer = 0;
}

1 REPLY 1

Slava Savitsky
Giga Sage

To indicate which days count as business days, you need to set up a schedule. After that, you can use methods of the GlideSchedule API to add time based on your defined schedule. This article by @Mark Stanger contains some examples you can use as a starting point.