I want to create catalog task after 30 or 60 or 90 or 180 days timer so how can i achieve this please share the code any one

shashidher1
Tera Contributor

I want to create catalog task after 30 or 60 or 90 or 180 days timer so how can i achieve this please share the  code any one 

below code am using but its not working:

// Set 'answer' to the number of seconds this timer should wait
var gdt = current.variables.EU26b;
if (gdt ==1) {
answer =86400;
} else if (gdt ==60) {
answer =5184000;
} else if (gdt ==90) {
answer =7776000;
} else {

answer =15552000;
}

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use workflow timer activity with script

Something like this for 30 days

var nowTime = new GlideDateTime();
var myDate = new GlideDateTime();
myDate.addDaysUTC(30); // add 30 days
var duration = GlideDateTime.subtract(nowTime, myDate);
answer = parseInt((duration.getNumericValue() / 1000));

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

how can i test its working or not so can you send add 5 min then we can test it its working or not 

 

Thankyou

 

Hi,

yes for 5mins do this

var nowTime = new GlideDateTime();
var myDate = new GlideDateTime();

myDate.addSeconds(300); // 5mins is 600 seconds

var duration = GlideDateTime.subtract(nowTime, myDate);
answer = parseInt((duration.getNumericValue() / 1000));

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur

Thankyou very much!!

 

Regards

Shashidher