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:47 PM
No task or catalog item ... in fact some cmdb_ci approval .. . Nothing OOB.
It's a group arroval ... so that might be the issue.
The code above ... this one should work within WF "run script" ? ... Sorry. Late already and I'm a low-code guy 😉

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 01:51 PM
Yes, it should be a 'Run Script' activity before re-entering the approval activity. Below is where I have my in my catalog item. But I can't imagine why it wouldn't work even on a CI. Though since you are doing group approvals, may be worth trying the second part of the disassociate function:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 02:05 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2017 02:15 PM
Actually I think I may know why it didn't work for you. Mine was a task based approval so sysapproval (a task reference) is usually where you go to get the task reference of an approval. Since you are working with CIs, you cannot use the task reference. There is another non-table specific field that we'll want to use, document_id.
Try this instead:
var apprRec = new GlideRecord('sysapproval_approver');
apprRec.addQuery('document_id', 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 02:24 PM
;-(
Also not working ...