Reset Change - UI Action not working correctly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2018 07:08 AM
Hi All,
We have a related Link UI action called 'Reset Change Workflow' on the change_request form. This resets the workflow and approvals of the change_request and returns it to the state of 'draft' :
This uses the 'SNC Approval - Reset Conditions' Before Update Business rule:
// these are the conditions under which the change request approvals need to be canceled and reset
// steps to activate
// 1. enable this business rule
// 2. add some comments so the reset will be noted in the approval history
// 3. uncomment the code for restart or reset based on your requirements
// 4. define the reset condition in checkResetConditions function below
// 5. you must set doReset once you capture the change(s) you are interested in
var comment = 'Approval reset by ' + gs.getUserDisplayName(); //written to the approval_history
if (checkResetConditions()) {
// create a global variable lock on the current record
// this will prevent triggering a second reset while the first reset is still in progress
// lock will be release in a late running business rule called 'Workflow Release Lock'
if (typeof GlideRecordLock != 'undefined')
chg_wf_lock = GlideRecordLock(current);
else
chg_wf_lock = new Packages.com.glide.script.RecordLock(current);
chg_wf_lock.setSpinWait(50); //wait for lock
if (chg_wf_lock.get()) {
gs.print('SNC Approval conditions business rule is locking the ' + current.getDisplayValue() + ' during the workflow reset');
// The following options are available for resetting the approvals:
//
// 1. Mark all existing approvals for the change as 'cancelled' and restart the workflow to create new approvals
new WorkflowApprovalUtils().cancelAll(current, comment);
new Workflow().restartWorkflow(current);
//
// 2. Delete all of the existing approvals for the change and restart the workflow to create new approvals
// new WorkflowApprovalUtils().reset(current, comment);
// gs.addInfoMessage('Workflow has been reset since key fields have been modified');
//
// 3. Leave the approvals for the change in their current state and restart the workflow.
// (so that any new approvals that are required will be created)
// if (comment)
// current.setDisplayValue('approval_history', comment);
// new Workflow().restartWorkflow(current, true);
//
}
//Use this section to reset any necessary information on the Change request
current.work_notes = 'Change approvals and workflow reset due to material change by ' + gs.getUserDisplayName();
current.approval = 'not requested';
//Use this section to reset any necessary information on any associated Change tasks
var tsk = new GlideRecord('change_task');
tsk.addQuery('change_request', current.sys_id);
tsk.query();
while(tsk.next()){
tsk.work_notes = 'Change request workflow reset.';
tsk.update();
}
gs.addInfoMessage('Change approvals and workflow reset for ' + current.number + '.');
}
function checkResetConditions() {
var doReset = false; //default to no reset
//add reset conditions here such as:
//if (current.assigned_to.changes())
doReset = true; //enable the reset
return doReset;
}
When we use this UI action it seems to push onto the next action of the workflow before resetting. This is leading to some approvals being added to the change even though it shouldn't have reached this point of the workflow yet.
As can be seen above, the change was at the Approval - Group 'Change Task Approval' stage when the UI action was selected. but it seems to have pushed onto the set values - approval and part way the to Approval Group - Change Manager Group Approval.
This has caused the Change Manager Group approval to be added. It has then reset the individuals approval requests (form the change manager group) in the approvers tab, but it has left the group approval still requested.
Any help on why this is happening?
Thanks
Sam
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2018 05:27 AM
Ok - just tried this in Kingston. While my UI action reset the Change state back to New, and the business rule ran, I'm using option 2 in the reset business rule, it did not remove the existing approvals, just marked them as cancelled.
I tried option 1 - and nothing happened, nothing changed. So your issue appears to be caused by Kingston.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 04:12 AM
Thanks Michael,
I've raised a Hi ticket to get this looked at. I will update once I hear back
Sam

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 05:35 AM
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2018 07:08 PM
Anything back on your ticket with HI support? Just started to look at this and see a new business rule that's also checking for a reset of the State. It also seems like you can reset the State back to New once it gets to Authorize.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2018 05:10 AM
Hi Michael,
Just had a response - they have raised PRB1265009 to put in a full fix.
As a workaround they have added a line in the 'WorkflowApprovalUtils' script include.
Previous - Line 526:
// If we are coming from a Reset Approvals with a state of Cancelled
// we do not want to progress the workflow further
if (approvalState === 'cancelled') {
gr.setValue("active", false);
gr.setValue("state", "4");
}
Fix - Line 526:
// If we are coming from a Reset Approvals with a state of Cancelled
// we do not want to progress the workflow further
if (approvalState === 'cancelled') {
gr.setValue("active", false);
gr.setValue("state", "4");
gr.setWorkflow(false);
}
They have added gr.setWorkflow(false); to line 531
Hope this helps
Sam