How to cancel open approvals via UI Action ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2017 05:21 AM
Hi,
I created a workflow (not on any task related table ... ) and it works fine.
After a UI action changes the status field the workflow approval will be set to cancelled
Current script in UI action;
function onClickl(){
if(confirm('Sure?')){
gsftSubmit(null, g_form.getFormElement(), 'action_name');
}
return false;
}
// Server side code
if(typeof window == 'undefined')
abC();
function abC(){
current.install_status= '123';
current.update();
var wf = new Workflow();
wf.cancel(current);
new WorkflowApprovalUtils().cancelAll(current, comment);
new Workflow().restartWorkflow(current);
}
When using the Ui Action, the approval in the workflow are set to cancelled (looks fine) .. nevertheless the approval tasks are still active for the approvers.
Additionally when restart the Workflow with the same conditions - old approvals already given will apply automatically ... .
I assume something is missing that will kill all approval tasks when using the ui action ... somehow I could not find it till now ...
Thank you!!
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2017 05:24 AM
You to have query the approval table and set the status to "No longer approval required". In that way the status is set and approval tasks are cancelled.
Thanks,
VInitha.K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2017 05:26 AM
ok sounds logically. How to do? Via a Business Rule that is trigged via the status?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2017 05:30 AM
Through run script activity in workflow,
gatherNLR();
function gatherNLR() {
var ga = new GlideRecord('sysapproval_approver');
ga.addQuery('state', 'requested');
var gr = ga.addQuery('sysapproval.approval', 'requested');
gr.addOrCondition('sysapproval.approval', 'approved');
gr.addOrCondition('sysapproval.approval', 'rejected');
var gr1 = ga.addQuery('sysapproval.state', '3');
gr1.addOrCondition('sysapproval.state', '6');
gr1.addOrCondition('sysapproval.state', '7');
ga.query();
gs.log('The sys_approval_approver table has ' + ga.getRowCount() + ' rows that needs to be in No longer Requested status...');
while (ga.next()) {
ga.setValue('state', 'No Longer Required');
ga.update();
}
}
Thanks,
Vinitha.K
PS: Hit answered, like, Helpful or Correct depending on the impact of the response.