- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2023 01:17 AM
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();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2023 02:31 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2023 02:31 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2023 03:03 AM
Yaaayyy, it worked, thank you so much.