- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2016 10:59 AM
I have a requirement to use the approve/reject feature on the grc_remediation table and the workflow works well.
However, the other requirement is to have the approval buttons (Approve/Reject) on the form itself, which I have created as UI Actions. So far so good. However, using the button script from Change, which is found below, it does not move the workflow forward when the button is used on the form itself.
current.approval = "approved"; //or rejected for the Reject button
current.update();
Can this be done? If so, how?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2016 08:46 PM
Figured it out!
I created a UI Action for both Approve and Reject Form buttons and this was the code that moved the workflow forward:
current.approval = "approved";
//current.update();
var ap = new GlideRecord('sysapproval_approver');
ap.addQuery('sysapproval', current.sys_id);
ap.query();
while(ap.next()){
ap.state = 'approved';
ap.update();
}
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2016 11:04 AM
To get it to move the workflow that is already started for it, you will have to do some workflow scripting:
Workflow Script - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2016 02:00 PM
Thank you Mike for this link. I have tried several of these scripts, including the one below, but to no resolution.
var wf = new Workflow().getRunningFlows(current);
while(wf.next()) {
new Workflow().broadcastEvent(wf.sys_id, 'resume');
}
Any ideas of what can be used?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2016 08:46 PM
Figured it out!
I created a UI Action for both Approve and Reject Form buttons and this was the code that moved the workflow forward:
current.approval = "approved";
//current.update();
var ap = new GlideRecord('sysapproval_approver');
ap.addQuery('sysapproval', current.sys_id);
ap.query();
while(ap.next()){
ap.state = 'approved';
ap.update();
}
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-30-2016 05:03 AM
HI Rhett,
Thanks for the UI action- Quite new to service now and I am having a problem
The workflow works for approve and reject.
However on my status it is saying completed
I would have hoped it showed like 'rejected'
This is the rejection UI action.
I was wondering if you had this issue?