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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-27-2022 11:22 PM
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-27-2022 11:24 PM
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
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-28-2022 01:29 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-28-2022 01:45 AM
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
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-28-2022 04:58 AM
Hi Ankur
Thankyou very much!!
Regards
Shashidher