Creating a related list for Change Request

ceraulo
Mega Guru

Hello!

I created a 'Create a Normal Change' from the Requested Item. In the Change Request form, I want to add a Requested Item related list that contains the Requested Item. This is similar to the 'Problems', 'Incidents Fixed By Change; related lists.

Please help.

Thanks!

 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Hi ceraulo,

I'll show you how to do this, but I want to make sure you understand the process here.  When you create a change from an RITM, the RITM is stored in the parent field of the change_request.  This means 2 things 1) you can show the Parent field on the change request form to see the RITM and since it's a reference field you can click through to the RITM, and 2) there's only going to be one RITM per change request created this way, so a related list is not ideal, but this can still be done if the parent reference field is not what you're looking for.

Go to System Definition -> Relationships in the left nav.  Create a new record.  Name it whatever you want to appear as the Related List name.  Applies to table = change_request.  Queries from table = task.  Your Query with script will simply be this.

(function refineQuery(current, parent) {
	current.addQuery('sys_id', parent.parent);
})(current, parent);

Now you can configure your change request form to add your new related list.

View solution in original post

6 REPLIES 6

Brad Bowman
Kilo Patron
Kilo Patron

Hi ceraulo,

I'll show you how to do this, but I want to make sure you understand the process here.  When you create a change from an RITM, the RITM is stored in the parent field of the change_request.  This means 2 things 1) you can show the Parent field on the change request form to see the RITM and since it's a reference field you can click through to the RITM, and 2) there's only going to be one RITM per change request created this way, so a related list is not ideal, but this can still be done if the parent reference field is not what you're looking for.

Go to System Definition -> Relationships in the left nav.  Create a new record.  Name it whatever you want to appear as the Related List name.  Applies to table = change_request.  Queries from table = task.  Your Query with script will simply be this.

(function refineQuery(current, parent) {
	current.addQuery('sys_id', parent.parent);
})(current, parent);

Now you can configure your change request form to add your new related list.

Hi Brad,

I tried what you suggested but it did not work. I also checked the Parent field in the Change Request but it wasn't populated. I added this line of code in my UI Action and it worked.

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

One thing I noticed is in the other related list such as Problems, there are 2 buttons - New and Edit. Any idea how I could do this for my custom related list?

find_real_file.png

 

Thank you.

 

 

@ceraulo 

for custom defined relationship Edit button is not allowed.

The New or Edit button does not appear on a one-to-many related list

Regards
Ankur

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

Thanks, Ankur.

When I go to Configure > Related List I see the below. The first 3 are OOB and the last one is what I created.

Why is my related list not showing the '->Change request'? 
Is it because my related list is custom?

find_real_file.png