Changing the REQ approval and request state when an RITM approval is rejected

Cupcake
Mega Guru

I would like to know the best practice for making these updates.

I am working on a project to update all workflows for all catalog items to ensure that everything is consistent. I've done that part, but upon TESTING out the changes. It has come to my attention that when an approval is rejected the RITM's State / Stage are correct, but the REQ Approval & Request State are not.

find_real_file.png

I've tried updating the workflow directly to include the request.request state = Closed Rejected but that didn't seem to add any value.

find_real_file.png

Should this be done via a UI Action or UI Policy?

Thanks,

Karen

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Karen,



Typically the request auto-closes when all of the items are completed or cancelled. If you're wanting to close the request when someone rejects an approval in one of the items, then all of the other items associated with the request would close too. Is that what you're wanting to do?



I think to close the request you would need to use a GlideRecord in a run script activity. The Set Values activity only works on the current record.


View solution in original post

5 REPLIES 5

Swarnalathay
Tera Contributor

 

Hi Kishore,

There are couple of mistakes in the script. Please try below.

 

(function executeRule(current, previous /*null when async*/) {

var request=current.request;

var gr=new GlideRecord('sc_request');

gr.addQuery('sys_id',request);

gr.query();

if(gr.next())

{

gr.request_state='closed_incomplete';

gr.update();

}

})(current, previous);