- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2017 03:58 AM
Hello Am using the below script to change the Change request status from implementation approval(1) to Closed(3) and sub status(cancelled ) to but its not working for me, can you suggest something.
var gr = new GlideRecord('change_request');
gr.addQuery('number', 'CHG0054828');
gr.query();
while(gr.next())
{
If (gr.state=='1');
gr.state='3';
gr.u_sub_status = 'cancelled';
gr.update();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2017 11:55 PM
Hello Mrudula,
Am running the script on Script back ground, i need the given change number to be closed cancelled irrespective of any stage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2017 06:30 AM
It should work,
Go to System Definition -> Fix Script & execute this one
var gr = new GlideRecord('change_request');
gr.addQuery('number', 'CHG0054828');
gr.query();
while(gr.next())
{
if(gr.state == 1);
gr.state = 3;
gr.u_sub_status = 'cancelled'; //put correct value
gr.update();
}
If you want to close all Change Request regardless of states then write Onload client script on Change Request table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2017 09:24 PM
Could you give us a little bit more background on where have you implemented this code script? Is it a UI action, workflow or BR etc?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2017 11:55 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2017 12:33 AM
Hi,
gr.state = '3'; Should be replaced with gr.state = 3;
Thank you,
Ashutosh Munot
Please close this thread if you got your answer by marking answer Correct or Helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2017 01:47 AM
Hi ,
I ran the below script and it executed as expected in my instance. Is your script executing till the end? Try gs.print statement to check until which point does it run. If it still does not update, check for some Business rule which might be aborting the update.
var gr = new GlideRecord("change_request");
gr.addQuery('number','CHG0040007');
gr.query();
if(gr.next())
{
gs.print("Number is "+gr.number);
gs.print("state now is "+gr.state);
gr.state = 5; // In my instance 5 value is assigned to "In progress" state
gr.update();
gs.print("state now is "+gr.state);
}