Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This UI Action adds an admin-only button to Flow Context records in ServiceNow. It is designed to expire active timers within a flow, allowing developers and testers to bypass waiting stages during sub-production testing. This helps accelerate flow validation and debugging during development cycles, especially useful during events like Hacktoberfest.

Flows in ServiceNow often include Wait for Condition or Wait for Duration steps that can delay testing. This UI Action provides a quick way to expire those timers, enabling the flow to proceed immediately without waiting for the configured duration or condition. Features

Adds a button labeled "Expire Timers" to Flow Context records. Visible only to users with the admin role. Executes a script to expire all active timers associated with the selected Flow Context. Ideal for sub-production environments (e.g., development, test, or staging). Speeds up flow development and validation.

<img width="1584" height="165" alt="image" src="https://github.com/user-attachments/assets/64d02ab2-de5b-48b6-82ac-d00771f43898" />
46 changes: 46 additions & 0 deletions Client-Side Components/UI Actions/Expire Timer in Flows/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
This script should be placed in the UI action on the table sys_flow_context form view.
This UI action should be marked as client.
Use runClientCode() function in the Onclick field.
*/
function runClientCode() {

if (confirm('Are you sure you want to Expire the Timer activity ?\n\nThis Action Cannot Be Undone!')) {
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'ExpireTimer'); //MUST call the 'Action name' set in this UI Action
} else {
return false;
}
}

if (typeof window == 'undefined') {
ExpireTimer();
}

function ExpireTimer() {
var grTrigger = new GlideRecord('sys_trigger');
grTrigger.addQuery('name', 'flow.fire');
grTrigger.addQuery('script', 'CONTAINS', current.sys_id);
grTrigger.addQuery('state', 0);
grTrigger.setLimit(1);
grTrigger.query();
if (grTrigger.next()) {
var grEvent = new GlideRecord('sysevent');
grEvent.initialize();
grEvent.setNewGuid();
grEvent.setValue('name', 'flow.fire');
grEvent.setValue('queue', 'flow_engine');
grEvent.setValue('parm1', grTrigger.getValue('job_context').toString().slice(6));
grEvent.setValue('parm2', '');
grEvent.setValue('instance', current.sys_id);
grEvent.setValue('table', 'sys_flow_context');
grEvent.setValue('state', 'ready');
grEvent.setValue('process_on', new GlideDateTime().getValue()); //aka run immediately
grEvent.insert();
grTrigger.deleteRecord();
gs.addInfoMessage("You have chosen to end any timers related to this flow.");
}


action.setRedirectURL(current);
}
Loading