Cancellation of Requests

Vengeful
Mega Sage

I am trying to cancel a change request using background script to SNow Dev, but it won't take effect.
State is open. Phase State is work in progress

//request cancelled

var gr=new GlideRecord('sc_req_item'); //table name

gr.addQuery('sys_id', 'c8247290dbd42d5043257e83e2961981');

gr.query();

while (gr.next()) {

gs.print(gr.number); //number is the element/column

gr.stage=’Request Cancelled’; // value of the phase

gr.state=’4’;

gr.update();

}

1 ACCEPTED SOLUTION

Sagar Pagar
Tera Patron

Hi @Vengeful,

 

Are you sure, you want to cancel the change requests?

As I can see the table name in scripts is Request item [sc_req_item]. It should be change_request for Change request.

 

Try this modified sample scripts and modify it accordingly -

 

 

var gr = new GlideRecord('change_request'); //table name
gr.addQuery('sys_id', 'c8247290dbd42d5043257e83e2961981');
gr.query();
if(gr.next()) {
gs.print(gr.number); //number is the element/column
gr.stage = ""; // add value of the phase
gr.state = "4"; // add value of the state
gr.setWorkflow(false);
gr.autoSysFields(false);
gr.update();
}

 

 

 

 

 

Thanks,

Sagar Pagar

The world works with ServiceNow

View solution in original post

2 REPLIES 2

Sagar Pagar
Tera Patron

Hi @Vengeful,

 

Are you sure, you want to cancel the change requests?

As I can see the table name in scripts is Request item [sc_req_item]. It should be change_request for Change request.

 

Try this modified sample scripts and modify it accordingly -

 

 

var gr = new GlideRecord('change_request'); //table name
gr.addQuery('sys_id', 'c8247290dbd42d5043257e83e2961981');
gr.query();
if(gr.next()) {
gs.print(gr.number); //number is the element/column
gr.stage = ""; // add value of the phase
gr.state = "4"; // add value of the state
gr.setWorkflow(false);
gr.autoSysFields(false);
gr.update();
}

 

 

 

 

 

Thanks,

Sagar Pagar

The world works with ServiceNow

Yaaayyy, it worked, thank you so much.