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

Brad Bowman
Kilo Patron
Kilo Patron

Hi Nivedita,

What process are you using to create a change from an incident?  You would have to look at this UI Action or whatever you're using, and change it to make sure the parent field is populated with the incident, then it will show on the out of box Change Requests related list that you add to your incident form.

Hi @Brad Bowman

I'm using OOB create change normal, standard one UI Action. Can you help me with the change you are talking about ?

Hi @Brad Bowman
I'm using OOB create standard,normal and emergency. Can you help me with change what you are talking about?

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