Approval Chains
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2013 08:30 AM
we have a requirement to gather approvals for all managers up to a certain point.
I have tried creating an IF -> Approval User loop in the workflow, but I've noticed two things. 1) the if statement isn't working after the first check, and 2) the approval user activity isn't generating new approvals after the first one. Or it's deleting the previous approvals associated to it.
Any ideas how I should implement this?
- Labels:
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2014 04:03 PM
Ugh. I just tried using a subflow. Unfortunately while the subflow works the parent workflow that invoked the subflow does not exit upon the subflow completing. So the parent workflow appears stuck. We are using the Berlin release of ServiceNow so I'm not sure if this is a known bug.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2014 02:26 AM
Hi Brian,
I have same problem that once the Approval - User activity is executed for the second time, the old Approvals are deleted from the system. After my investigation I have realized that this is coded in the Workflow Activity definition. There is function "_checkDroppedApprovals" which is called during the execution of the activity. The description of the function is "Delete any approvals that we previously created but did not match during this creation pass".
I have tested little bit on demo instance how this could be resolved. Firstly I have tried to basically remove the deletion code (comment or remove the row with gr.deleteRecord() in the function) in the OOTB activity definition and this looks working. Approvals are not deleted anymore and new ones are created. It even looks that the approval strategy is working correctly so that if you update (approve/reject) an old one approval this does not affect the current activity execution. Only once you approve a new approval the activity execution is completed.
Unfortunately I would not like to customize OOTB workflow activity definition since it can be used by other workflows as well and the OOTB activity should be still available. So I have tried to copy the existing activity definition with all variables, conditions and UI policies and customize this newly created activitiy definition, but this does not work for me. From some reason the activity is skipped - not sure why.
But generally I think that it should work - copy existing Approval - User activity and customize it in the way that deletion part will be omitted and use this new activity within the workflow which is cycled and where the same approval activity is executed multiple times.
Other option could be to use Run Script activity instead of Approval activity and create approvals within a script and handle approved/rejected decision on your own.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2014 01:05 AM
Hi,
At the end we have updated one function in the definition of Approval - User activity:
_createApprovals: function(state, approvalOrder) {
this.existingIds = this._getExistingApprovals();
var userIds = this._getUserIds();
var approvalIds = this._buildApprovals(userIds, state, approvalOrder);
// Customization Start
var gr = new GlideRecord('wf_context');
gr.addQuery('table', <your-table>);;
gr.addQuery('state', 'executing');
gr.addQuery('id', current.sys_id);
gr.addQuery('workflow', <sys_id-of-your-workflow>);
gr.query();
if (!gr.hasNext()) {
// Check Dropped Approvals only if this activity is not called in our workflow
this._checkDroppedApprovals(approvalIds);
}
// Customization end
return approvalIds;
},
This helped that previously created approvals are deleted only if the Activity is run in other workflow than ours. So this solution should not affecte other workflows but our cycled workflow is working as we want.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2019 06:01 AM
Hi Dominik
I used a different approach (see https://community.servicenow.com/community?id=community_question&sys_id=fccf7e6ddb58dbc01dcaf3231f96...)
The key is to update wf_activity of approved approvals to the empty string, because the code to get the existing approvals is based on the wf_activity value.
Best
Daniel
If this answer was helpful, I would appreciate if you marked it as such - thanks!
Best
Daniel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 09:47 AM
Used the solution listed and I'm having an issues with the second Approval user activity, it's being skipped and not setting the approver. Any hints as to why. I changed line 4 to answer.push(grUser.manager.name); to use the name field instead of the user_name but, have tried both with the same result