- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2016 11:51 AM
Hi all,
We currently have a script that allows for approval escalations which flows as follows:
- Item is requested and manager approval is required.
- If 2 days goes by and the manager has not approved, escalate to the manager's manager.
- 2 days later, repeat this process and escalate to the manager's manager's manager.
The script checks to see if the next manager in the chain is a VIP:
- If the next manager is VIP, stop execution of the approval escalation workflow.
- If the next manager is NOT a VIP, continue to escalate up the chain every 2 days.
Now functionally the script is taking the old manager out of the approval record, replacing it with the manager that the approval was escalated to and calling .update(). Which means that if the original approving manager suddenly grants approval 2.5 days in, after it has escalated, the approval is discarded because that particular manager is no longer listed as an approver.
I experimented with changing .update() to .insert(), which works in the sense that both managers are listed as a potential approver. The problem is that the Request Item stands still until both approvals are received (Original Manager and any Escalated Managers).
We want to fix this so that any manager in the escalation chain can approve, and if any one person does approve, the remaining approvals are no longer required. Anyone have any thoughts or suggestions that might put me on the correct path?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2016 07:12 PM
I was reading up on workflows and remembered that workflows terminate the moment End is reached, so I came up with an alternate approach that should work very nicely, feels much cleaner, can be expanded upon and helps keep the process closer to being 'out of the box'.
First I created a new subflow called GetManagerApproval:
I then added the following variable to GetManagerApproval's subflow properties, which is assigned a yes/no value in the two run scripts (approved/rejected) just prior termination:
And then created an example workflow for the Service Request Item:
Double-clicking the GetManagerApproval activity, I set the 'Map to return value' to match the variable previously created (The If activity tests this variable for a yes/no, returned from the subflow, and acts accordingly):
It works perfectly whether I stop it at 1st, 2nd or 3rd level. And I figured there's a problem if you are having to escalate 3 or more times for approval. But if it should be needed I can simply add another layer or two into the subflow:)
Let me know if you have any questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2016 05:33 AM
I'm not sure why without seeing your code / structure. Can you navigate to the item that you approved, click 'Show Workflow' and attach a screenshot to this thread?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2016 07:34 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2016 05:34 AM
Can you post a screenshot of each of the following?
- The code for the If activity (if Approved) in the parent workflow, following the subflow activity.
- The window that appears when you double-click 'Mark as rejected'.
- The code for the Run Script that follows 'Mark as rejected'
- The subflow properties that shows the workflow variable you created.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2016 04:41 AM
Hi All,
I've added all of them under one workflow and its working fine. but whenever second user , approve the request , its leaving other approval state to Requested instead of setting to cancelled or "no longer required". How can i set it so that when Primary user didn't approve the request within 1 day it will go to second user by cancelling primary user approval request set to Cancelled?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2016 12:42 PM
i believe using the approval utilities after your timer you can test if it is approved.. .if not i would run a utility to cancel all existing approvals and would set them to "No longer required" and THEN generate a new approval
WorkflowApprovalUtils - ServiceNow Wiki
using this one for example you can set all pending aprovals for the task to "No longer required" or cancelled and add a comment.. then create a new approval
setUserApprovalsByTask(taskID, approvalState, comment, ['not requested', 'not_required', 'requested']
i would change the not_required to whatever your requested approval state is
3.18.1 Input Fields
Parameters:
- taskID - sys_id of the task to set all user approvals. The task does not have to be derived from the task table.
- approvalState - The new state to set all the group approvals to.
- comment - Optional string comment to apply to the approval state transition