Trigger a task before 2 Business days using a Workflow Timer activity getting stuck and not working

shyamkrishna
Giga Contributor

HI 

 

I have a workflow to create a task 

 

But the condition is , there is a variable called Effective Date . 

 

If the Effective date 2 business Days before the current Date , create the task immediately 

 

If the Effective date 2 business Days after the current Date , don't create the task immediately and wait for two days to create the task 

 

There is a issue

 

Task is always getting created 

 

1. Script is not working , if i select an Effective date 2 days before today . 

 

answer = 0;
var gdt = new GlideDateTime();
//date is the field name of the Date variable
gdt.setDisplayValue(current.variables_pool.effective_date.getDisplayValue());
var currentDate = new GlideDateTime();
var currentSeconds = currentDate.getNumericValue();

gdt.subtract(currentSeconds);
gdt.subtract(2*24*60*60*1000); // get two days before

var sched = new GlideSchedule('ae4d49031b017910c9ebfc038d4bcb3e'); // sys_id of business day schedule
while (!sched.isInSchedule(gdt)) { // check if day is a business day
gdt.subtract(2*24*60*60*1000); // get two days before
}

answer = gdt.getNumericValue();

shyamkrishna_0-1694099659486.png

 

 

Timer Script 

 

 

0 REPLIES 0