a way to update the work notes for the related issue record

honamiUeo
Tera Contributor

Is there a way to update the work notes for the related issue record when the change management is closed?

Best regards, and thank you in advance.

 

changerequest1.pngchangerequest2.pngchangerequest3.png

1 ACCEPTED SOLUTION

@honamiUeo 

yes it's possible.

you can use after update BR on Change Request Table

Condition: State Changes to Closed

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var gr = new GlideRecord("problem");
	gr.addQuery("rfc", current.getUniqueValue());
	gr.query();
	while (gr.next()) {
		gr.work_notes = 'The associated change request ' + current.number + ' is closed';
		gr.update();
	}

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

@honamiUeo 

yes it's possible.

you can use after update BR on Change Request Table

Condition: State Changes to Closed

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var gr = new GlideRecord("problem");
	gr.addQuery("rfc", current.getUniqueValue());
	gr.query();
	while (gr.next()) {
		gr.work_notes = 'The associated change request ' + current.number + ' is closed';
		gr.update();
	}

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

Thank you very much.
My wish has been granted by following your instructions.