- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2018 08:24 AM
We have a "consent through silence" approach in our workflows where the system owner has 3 days to approve a RITM before it is auto-approved. The potential issue is what happens if the RITM is manually approved. Later in the workflow we have a Join activity that gets hung up because the timer is still running. While I don't think most requests will get done before the timer ends, we want to be sure it doesn't become an issue in production. I'm not sure what we could put in the workflow or a business rule to cancel this timer; any suggestions?
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2018 06:00 AM
My coworker was able to use feedback from another post to come up with a solution. Sharing in case it helps others.
In the workflow we added a Run Script after the approval task that runs if the task is marked approved. The script then checks the ongoing activities based on name and it's activity index # to see if it exists and delete it. For our workflows the index # could vary so there has to be an Or condition to check more than one possibility.
var wf = new GlideRecord("wf_context");
wf.addQuery('sys_id', current.context);
wf.query();
while (wf.next())
{
var wfe = new GlideRecord("wf_executing");
wfe.addQuery('context', wf.sys_id);
wfe.addQuery(activity.getDisplayValue(); "Activity Name");
var qc = wfe.addQuery('activity_index', #);
qc.addOrCondition('activity_index, #);
wfe.query();
while (wfe.next())
{
wfe.deleteRecord();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2018 06:00 AM
My coworker was able to use feedback from another post to come up with a solution. Sharing in case it helps others.
In the workflow we added a Run Script after the approval task that runs if the task is marked approved. The script then checks the ongoing activities based on name and it's activity index # to see if it exists and delete it. For our workflows the index # could vary so there has to be an Or condition to check more than one possibility.
var wf = new GlideRecord("wf_context");
wf.addQuery('sys_id', current.context);
wf.query();
while (wf.next())
{
var wfe = new GlideRecord("wf_executing");
wfe.addQuery('context', wf.sys_id);
wfe.addQuery(activity.getDisplayValue(); "Activity Name");
var qc = wfe.addQuery('activity_index', #);
qc.addOrCondition('activity_index, #);
wfe.query();
while (wfe.next())
{
wfe.deleteRecord();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2024 07:22 AM
Hey where di you add the run script. I have a similar condition where a CTask & Timer are parallely created and despite the task being closed, RITM stays open until xtimer is completed.. Can you guide on how to close the RITM immediately after the task is completed. Because of the Timer running, the closed complete node of the CTask is not executing

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2020 12:18 PM
I know this post is two years old, but I recently had the need to use it to cancel a workflow and I found there were a couple of typos that caused it to not work. I am sharing the version that worked for me here in case someone else wants to use it. I moved the variables that need to be customized to the top to make it easier to see what needs changing.
var actName = "<your_activity name>";
var contextid = "<your_wf_context_sysid>"; //Inside workflow, I used: activity.context
var actIndex1 = "<your_activity_index_1>";
var actIndex2 = "<your_activity_index_2>"; //if needed
var wf = new GlideRecord("wf_context");
wf.addQuery('sys_id', contextid);
wf.query();
while (wf.next())
{
var wfe = new GlideRecord("wf_executing");
wfe.addQuery('context', wf.sys_id);
wfe.addQuery('activity.name', actName);
var qc = wfe.addQuery('activity_index', actIndex1);
qc.addOrCondition('activity_index', actIndex2); // Can comment out if not needed
wfe.query();
while (wfe.next())
{
wfe.deleteRecord();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2023 11:16 AM
Deleting the record seemed (potentially?) problematic, but this script instead will cause the Timer to end based on current datetime.
killTimer();
function killTimer() {
var actName = "Timer Activity Name";
var eQuery = 'context.id=' + current.sys_id + '^activity.name=' + actName;
var wfe = new GlideRecord("wf_executing");
wfe.addEncodedQuery(eQuery);
wfe.query();
if (wfe.next()) {
var trig = new GlideRecord("sys_trigger");
trig.addQuery('document_key', wfe.sys_id);
trig.query();
if (trig.next()) {
var gdt = new GlideDateTime();
trig.next_action = gdt;
trig.update();
}
}
}