- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2018 06:09 AM
Hi All,
One of my colleagues has added a new UI Action 'Reset Change Workflow' to our change Request form. This is meant to allow users to reset the change back to draft at any stage of the workflow, and it will cancel all the approvals, and reset the workflow so any changes can be made and then it can be sent back round the workflow.
When we try the UI action as an Admin it is working and the log goes back to draft etc. When we try with an ITIL user the UI action is there to select, but it is not performing the actions.
on a HI ticket they have mentioned they are seeing the following:
Uncaught ReferenceError: RiskAssessmentCalculator is not defined "
The UI action is set as:
And this uses the following 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;
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2018 06:27 AM
Hi Sam
It might be something to do with ACLs. Check if there is anything on the change_request.state field and if so, try deactivating it.
Hope this helps.
Matt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2018 02:36 AM
Hi Stephen,
Apologies in the delay replying - the ACL seems to have been the issue.
Thanks for your help
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2018 09:09 AM
Unfortunately we are still having this issue. deactivated the ACL, and the hasRole is fine.