How to disassociate approvals from workflow before running again?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 10:00 AM
Hi Experts,
I have an approval workflow. In case of rejection, it will be possible to request approval again.
As I do not like to delete all approvals, I need to find a way to just disassociate the approvals that happened before to be able to run the workflow again.
Without doing this, the rejection given before will still "stuck-point" of the workflow as long no other approves are within the approval group.
In the change management, I found some skipt running (new ChangeRequestStateHandler(current).disassociateApprovalsFromWorkflow();) ... but this will not work here, as I'm not using states here so far ... .
Any other option?
Thank you so much!
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 01:05 PM
This works for me in an approval subflow I have in catalog workflows:
var apprRec = new GlideRecord('sysapproval_approver');
apprRec.addQuery('sysapproval', current.sys_id);
apprRec.query();
while (apprRec.next()) {
apprRec.wf_activity = '';
apprRec.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 01:18 PM
Looks absolutely correct for me and would make sense.
Unfortunately it does not work.
Still the rejected approval "counts" and no new approval will be forced the 2nd time ;-(

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 01:22 PM
Can you share more of your workflow and the context? Is it a catalog item or on another task type,etc.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 01:26 PM
If you look at the dissociate function in your instance, you'll see it follows a similar model (though covers group approvals too):
/**
* Dissociate approvals from a particular workflow activity to preserve the history.
*/
disassociateApprovalsFromWorkflow: function() {
if (!this._gr)
return;
var existingApprovalsGr = new GlideMultipleUpdate("sysapproval_approver");
existingApprovalsGr.addQuery("sysapproval", this._gr.getUniqueValue());
existingApprovalsGr.addQuery("state", "!=", "cancelled");
existingApprovalsGr.setValue("wf_activity", "");
existingApprovalsGr.execute();
existingApprovalsGr = new GlideMultipleUpdate("sysapproval_group");
existingApprovalsGr.addQuery("parent", this._gr.getUniqueValue());
existingApprovalsGr.addQuery("approval", "!=", "cancelled");
existingApprovalsGr.setValue("wf_activity", "");
existingApprovalsGr.execute();
},