Notifications

31 views

Description

When a Change Request is put on-hold and then resumed with outstanding approvals, user approvals are not being reset to "Requested".

Steps to Reproduce

  1. Ensure that a user group has a manager.
  2. Move a low-risk normal change request that is assigned to this user group to the 'Authorize' state. You should now have a single user approval for the group's manager.
  3. Move the change request to On-hold and save. Notice that the manager's approval is set to 'No longer required'.
  4. Move the change request out of On-hold and save. Notice the manager's approval is not set to 'Required'.

Workaround

This problem has been fixed. If you are able to upgrade, review the Fixed In section to determine the latest version with a permanent fix your instance can be upgraded to.


If a workaround is required on older releases, the updates below should be made to the methods that reset approvals in the 'ChangePolicyApprovalActivity' script include, which extends ChangePolicyApprovalActivitySNC.
Paste the functions listed below between the 'initialize' and 'type' declarations in the script field of the script-include, so to override the behavior defined in ChangePolicyApprovalActivitySNC:


_setApprovalState: function(approvalId, state) { 
    if (this._workflow.scratchpad.maintainStateFlag == true) 
        return;

    var appGR = new GlideRecord("sysapproval_group"); 
    appGR.addQuery("sys_id", approvalId); 
    appGR.query(); 

    if (!appGR.next()) { 
        appGR = new GlideRecord("sysapproval_approver"); 
        appGR.addQuery("sys_id", approvalId); 
        appGR.query(); 
        if (!appGR.next()) 
            return; 
    } 

    appGR.setValue("sysapproval_group" === appGR.getRecordClassName() ? "approval" : "state", state); 
    if (this.setDatesFlag) { 
        appGR.expected_start.setValue(this.expected_start); 
        appGR.due_date.setValue(this.due_date); 
    } 

    appGR.update(); 
}, 

_getExistingUserApprovals: function() { 
    var ids = {}; 

    var gr = new GlideRecord("sysapproval_approver"); 
    gr.initialize();  
    // We work with the change_request table only, so we can depend on sysapproval field 
    gr.addQuery("sysapproval", this._gr.sys_id); 
    gr.addQuery("wf_activity", this._activity.activity.sys_id); 
    gr.addQuery("state", "!=", this.CANCELLED);
gr.addNullQuery("group"); gr.query(); while (gr.next()) ids[gr.approver.toString()] = gr.sys_id.toString(); return ids; }, onUpdate: function() { if (this.log.atLevel(GSLog.DEBUG)) this.log.debug("[onUpdate] Checking approval state"); // As per the workflow, when the change_request is put on hold we need to wait until it is no longer on hold, // so the activity needs to be completed, by setting the state and result to finished. // When it is no longer on hold the activity will be re-evaluated and existing approvals will be restored. if (this._gr.on_hold.changesTo(true)) { this._activity.state = this.FINISHED; this._activity.result = this.FINISHED; return; } this._onUpdate(); },

 


Related Problem: PRB1361797

Seen In

SR - ITOM - CMDB CI Class Models - 201907
SR - ITOM - Discovery and Service Mapping - v1.0.35

Fixed In

Madrid Patch 8
New York Patch 2
Orlando

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2020-03-02 10:51:20
Published:2020-03-02