- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2022 12:52 AM
Hi,
Our change request is configured in such a way that once any change request is closed, all the fields become read-only.
Now we have a requirement where, we need to update the close code from "successful" to "successful with issues" if any incident has been created related to change after the closure of the change request.
Kindly help me through this as i am new to scripting.
Thanks in Advance!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2022 01:11 AM
Hi
You can write a business rule on incident table as below
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('change_request');
gr.addQuery('sys_id',current.caused_by);
gr.query();
if(gr.next())
{
gr.close_code = "successful_issues"; //check value of successful with issues.
gr.update();
}
})(current, previous);
Mark as correct and helpful if it works.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2022 01:02 AM
Hi Sahana,
You need to create an OnAfter business rule, which will trigger if the "Caused by Change" is not empty.
// script in BR
fetch the change request using the Caused by Change field
update the Code to Closed with Issues
I would also recommend to add some notes in the changes and mention the incident due to which this has happened.
Please mark this as correct or helpful if this works.
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2022 01:04 AM
Hi,
can you please help with the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2022 01:42 AM
Here you go
var grChange = new GlideRecord('change_request');
grChange.addQuery('sys_id',current.caused_by);
grChange.query();
if(grChange.next()){
grChange.close_code = 'successful_issues';
grChange.update()
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2022 01:11 AM
Hi
You can write a business rule on incident table as below
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('change_request');
gr.addQuery('sys_id',current.caused_by);
gr.query();
if(gr.next())
{
gr.close_code = "successful_issues"; //check value of successful with issues.
gr.update();
}
})(current, previous);
Mark as correct and helpful if it works.
Regards,
Sumanth