
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 11:24 AM
It used to be the sys_trigger.list and look for WFTimer+sysid of the activity. But not sure what has happened or it is new in london, I cannot find the record WFTimer+my sysid in sys_trigger.list
Does anyone know if something changed with this?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 03:57 PM
solution is here.
https://community.servicenow.com/community?id=community_question&sys_id=9eb0dc83dbaeaf00f21f5583ca961921&view_source=searchResult

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 11:30 AM
Please see solution below to force workflow timer to complete
https://community.servicenow.com/community?id=community_question&sys_id=894bfa8ddbd9d3082d1efb651f961944
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 02:37 PM
I tried the script on this page slightly modified for us.
forceTimerComplete();
function forceTimerComplete() {
//how much time do you want to add to the timer from now. Expiration will be right now + newSeconds.
var newSeconds = 30;
var ID = current.sys_id;
//get the workflow context id for the current request item.
//i'm using this for a very specific timer, so i only want 1 result. if you want more, change the if to a while
var context = new GlideRecord("wf_context");
context.addQuery("id", ID);
context.query();
if(context.next()){
gs.log("Timer 1");
// find the specific executing activity from the context above.
var time = new GlideRecord("wf_executing");
time.addQuery('context', context.sys_id);
time.addQuery('state', 'waiting');
time.query();
if(time.next()){
gs.log("Timer 2");
//set the name for the workflow timer
var WFTimer = "WFTimer" + time.sys_id;
//search the sys_trigger table for the current timer
var schedule = new GlideRecord("sys_trigger");
schedule.addQuery("name", WFTimer);
schedule.query();
if(schedule.next()){
gs.log("Timer 3");
var curTime = schedule.next_action.getDisplayValue();
var gdt = new GlideDateTime();
gdt.addSeconds(newSeconds);
schedule.next_action = gdt;
var schedDisp = schedule.next_action.getDisplayValue();
schedule.update();
gs.addInfoMessage("<br><br><br><br><center><font size = 5>You have chosen to end the timer NOW<br>Timer will now expire at: </font><font size= 5 color='ff0000'>" + schedDisp + "</font><font size=5><br><br> which is " + newSeconds + " seconds from now.</font></center><br><br><br><br>");
current.work_notes = "Time has been expired early.\nTimer will now be expired at: '" + schedDisp + "' instead of '" + curTime + "'.";
current.update();
}
}
}
action.setRedirectURL(current);
}
The 3rd log statement is not executing because the record is not in the sys_trigger table. This is what I faced in my first try.
I guess something has changed now..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 03:57 PM
solution is here.
https://community.servicenow.com/community?id=community_question&sys_id=9eb0dc83dbaeaf00f21f5583ca961921&view_source=searchResult

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2022 11:18 AM
Needed to make some minor updates to get it to work with latest release.
Steps:
1) Create a new UI Action on the 'sc_req_item" table.
2) Name: Force Timer Complete
3) condition (optional if you want to restrict to admin only): gs.hasRole('admin')
Script:
forceTimerComplete();
function forceTimerComplete() {
//how much time do you want to add to the timer from now. Expiration will be right now + newSeconds.
var newSeconds = 30;
var ID = current.sys_id;
//get the workflow context id for the current request item.
//using this for a very specific timer, so only 1 result. If you want more, change the if to a while
var context = new GlideRecord("wf_context");
context.addQuery("id", ID);
context.query();
if (context.next()) {
gs.log("Timer 1");
// find the specific executing activity from the context above.
var time = new GlideRecord("wf_executing");
time.addQuery('context', context.sys_id);
time.addQuery('state', 'waiting');
time.query();
if (time.next()) {
gs.log("Timer 2");
//set the name for the workflow timer
var WFTimer = "Workflow" + time.context.sys_id;
//search the sys_trigger table for the current timer
var schedule = new GlideRecord("sys_trigger");
schedule.addQuery("name", WFTimer);
schedule.query();
if (schedule.next()) {
gs.log("Timer 3");
var curTime = schedule.next_action.getDisplayValue();
var gdt = new GlideDateTime();
gdt.addSeconds(newSeconds);
schedule.next_action = gdt;
var schedDisp = schedule.next_action.getDisplayValue();
schedule.update();
gs.addInfoMessage("<br><br><br><br><center><font size = 5>You have chosen to end the timer NOW<br>Timer will now expire at: </font><font size= 5 color='ff0000'>" + schedDisp + "</font><font size=5><br><br> which is " + newSeconds + " seconds from now.</font></center><br><br><br><br>");
current.work_notes = "Time has been expired early.\nTimer will now be expired at: '" + schedDisp + "' instead of '" + curTime + "'.";
current.update();
}
}
}
action.setRedirectURL(current);
}