how to update a read-only field once the change request is closed

Sahana Chandras
Tera Contributor

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.

find_real_file.pngfind_real_file.pngThanks in Advance!

1 ACCEPTED SOLUTION

SumanthDosapati
Mega Sage
Mega Sage

Hi @Sahana Chandrashekara 

You can write a business rule on incident table as below 

find_real_file.png

 

(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);

find_real_file.png

 

 

Mark as correct and helpful if it works.

Regards,

Sumanth

View solution in original post

5 REPLIES 5

ideamax
Mega Expert

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

Hi,

 

can you please help with the script

 

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()
}

SumanthDosapati
Mega Sage
Mega Sage

Hi @Sahana Chandrashekara 

You can write a business rule on incident table as below 

find_real_file.png

 

(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);

find_real_file.png

 

 

Mark as correct and helpful if it works.

Regards,

Sumanth