Change Request Related List

Nivedita
Mega Expert

Hello All,
I have a requirement when change is created from incident it should be shown under "change request" related list. I started working and find out that parent field on change record doesn't hold incident number automatically. So how can I do this?

1 ACCEPTED SOLUTION

In the UI Actions menu in the left nav, find the record named Create Normal Change that is on the incident table.  In the Script, just before the line that says changeRequest.insert(); add this line.

changeRequest.setValue("parent", current.sys_id);

Now you will see on the resulting Change Request that is created, the Parent field is populated with the Incident.

Repeat the same process for the UI Action named Create Emergency Change.

Standard works differently as it uses an interceptor, which opens a template, which includes none of the incident field values.  Populating the Parent field when using this UI Action will probably be easiest with an after Update Business Rule running on the incident table with the Filter Condition Change Request changes.  The BR script will do a GlideRecord to lookup the Change record, then populate the Parent field if it is not already.

(function executeRule(current, previous /*null when async*/) {
	var chg = new GlideRecord('change_request');
	if(chg.get(current.rfc)){
		if(chg.parent == ''){
			chg.parent = current.sys_id;
			chg.update();
		}
	}
})(current, previous);

View solution in original post

6 REPLIES 6

Thank you for the help.

You are welcome.