- 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 04:12 AM
Hi,
Try below;
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();
}
Thank you,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2017 04:26 AM
Try 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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2017 04:36 AM
Hi Krishna,
In your code the "IF" statement has wrong syntax.
Try below code :
var gr = new GlideRecord('change_request');
gr.addQuery('number','CHG0054828');
gr.query();
if(gr.next())
{
if(gr.state=='1')
{
gr.state='3';
gr.u_sub_status ='cancelled';
gr.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2017 05:56 AM
All these scripts are not working as expected, can we change directly to Closed state from No matter what state it be?