How to check all approvals are approved & set incident state to inprogress?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2017 08:52 AM
Hi All,
Please help me with How to check all approvals are 'approved' & set incident state to in-progress ? and if any one approval is in 'requested' state then incident state should be in 'pending'.
Once Approver is added or any approval is in requested state then — Incident Status is change to 'Pending Approval' and If approval is rejected or approved incident is changed to 'in progress' status.
// tried gliding both approver table & incident table but not working as per expected.
var number = current.sys_id;
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery("sysapproval", number);
gr.query();
while(gr.next()) {
var st = gr.state;
if(st == 'approved' || st =='rejected'){
current.state = 2; //in progress
current.update();
}
if(st =='requested') {
current.state = 3; // pending
current.update();
}}
Thank You.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2017 08:59 AM
Hello Banupriya,
See if below thread helps:
How to check whether all the approvals are completed ?
Thanks,
Abhishek
If this reply assisted you, please consider marking it Correct, Helpful, or Like it.
This helps other customers to learn from your thread.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2017 08:59 AM
why don't you use condition for approval in the approval activity. once all will approve then use set value activity and make the incident state in-progress.
Approval - User workflow activity

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2017 09:29 AM
no workflow for Incident management.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2017 09:35 AM
are you able to access "st" variable in if condition. can you please use log
var st ='';
var number = current.sys_id;
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery("sysapproval", number);
gr.query();
while(gr.next()) {
st= gr.state;
if(st == 'approved' || st =='rejected'){
current.state = 2; //in progress
current.update();
}
gs.log('value is:'+st);
if(st =='requested') {
current.state = 3; // pending
current.update();
}