Create a catalog task at next day morning at 6 am through workflow when 'Expiration date' is today

Mani Polisetty2
Tera Contributor

Hi ServiceNow Folks,

 

I need a help on to create a catalog task at next day morning at 6 AM through workflow when 'Expiration date' (date type only) variable is today. I have used timer activity but it's not working as expected.

 

I have written following script in timer activity.

 

var gdt = new GlideDateTime(current.variables.expiration_date);
gdt.addDays(1);
answer = gs.dateDiff(gs.nowDateTime(), gdt, true);
 
Thanks
Mani Polisetty
2 REPLIES 2

AshishKM
Kilo Patron
Kilo Patron

Hi @Mani Polisetty2 , 

 

You have to consider some execution path here, 

1) Once the workflow trigger the first time , apply the If condition to check if today's date is expiration date , if yes, then apply the timer to wait till 6 AM next day.

2) if step 1 return false then add the timer to wait till expiration date and loop to If condition, on expiration date the timer will again call to if condition and this time it will true.

3) after if condition return true , the next timer to wait till current date/time+1 ( next day ) 6:00AM for catalog task.

 

If you already developed some execution path, please share the screen shot.

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Hi Ashish,

 

Great thanks for your response, I have created following workflow for this requirement. The process is
1) Reporting manager approval

2) Group Approval

3) Create catalog task after completed the approvals

4) I have added the Timer for 'Send email notification 7 days before on Expiration Date Variable'  sending an  email notification 7 days before on Expiration Date Variable value. Using following script and it's working as expected in background scripts.

var gdt = new GlideDateTime(current.variables.expiration_date);
gdt.addDays(-7);
answer = gs.dateDiff(gs.nowDateTime(), gdt, true);
5) Once above condition is triggered, create another task at next day 6AM when Expiration Date Variable is today. In the Timer activity I have used following script.
 
var gdt = new GlideDateTime(current.variables.expiration_date);
gdt.addDays(1);
gdt.addSeconds(21600);
answer = gs.dateDiff(gs.nowDateTime(), gdt, true);
 
Please help. Thanks