How to streamline normal change request with multilevel approval via Flow Designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 05:35 AM - edited 07-26-2023 05:38 AM
Hello Team,
I have a requirement to build a custom approval for Normal change under the Assess phase. During the Assess stage the client wants 4 levels of group approval like-peer review approval, change team approval, primary and secondary service owner approval. In order to achieve this I have built a custom flow designer using the "Ask for approval" action. However, I have noticed slowness during the approval stages where the user had to refresh the page to see the progress, and on top of that when the user click on "revert to new" ui button the approvals continue to progress where the expected behavior is to reset the flow which did not happen. I raised a case with ServiceNow and was told that the "revert to new" functionality will work only with OOB "Approval policy" action from the OOB Flow designer.
I created a BR and was able to cancel the custom flow but when the user clicks on "request for approval" ideally the approval should start from the scratch in Assess phase instead it just continues from where it stopped in the canceled flow. for example -
Please help me with some solution. Also is there a way to improve the Flow designer approval as i had to refresh the screen everytime to see the changes applied to the form.
BR to cancel the Flow
(function executeRule(current, previous /*null when async*/ ) {
// Check if the Change State field has been modified from 'Assess' to 'New'
if (current.state == -5 && previous.state == -4) { // Change state -5: 'New', Change state -4: 'Assess'
// Find all approval records requested for this change request
var approvalGR = new GlideRecord('sysapproval_approver');
approvalGR.addQuery('sysapproval', current.sys_id); // 'current' refers to the Change Request record
approvalGR.addQuery('state', 'requested'); // Filter by requested approvals
approvalGR.query();
// Loop through the requested approvals and update their state to 'No Longer Required'
while (approvalGR.next()) {
approvalGR.state = 'not_required';
approvalGR.update();
}
// Cancel the Flow Designer associated with this Change Request
var now_GR = new GlideRecord("sys_flow_context");
now_GR.addQuery("name", "Change - Normal - Assess_Updated");
now_GR.query();
while (now_GR.next()) {
sn_fd.FlowAPI.cancel(now_GR.getUniqueValue(), 'Canceling Test Flows');
}
}
}
)(current, previous);
- Labels:
-
Change Management