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

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.


Brad thank you for the information. Based on the information that you provided, I will take this advice. I've advised the customer that this should not be done because the OOB functionality already in place to auto close when all of the items are completed or cancelled. In addition, other functionality has been put in place for RITM's, etc. where this update could have a negative impact.



So we will leave this alone for now and revisit if the issue arise again in the future.


Your advice is much appreciated.



Karen


Hi Brad Tilton,



can you please share the code what kind of script we have to write here..



i have created BR , but not working....


Script is:


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



var request=current.request;


var ge=new GlideRecord('sc_request');


gr.addQuery('sys_id',request);


ge.query();


if(gr.next)


{


ge.request_state='closed_incomplete';


gr.update();


}






})(current, previous);


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);