How can i get ritm related catalog task numbers in change form related list

Hari nadh
Tera Guru

find_real_file.png

This RITM contine 4 catalog task record i want that catalog task in related list of change form 

13 REPLIES 13

Community Alums
Not applicable

RITM and Task is one to many Relationship.

One ritm to mupltiple task.

You can get only those fields from ritm on the related which are present on RITM record.

Task are related record of RITM.

So you can do one thing ,if your change Request is having stored on RITM then you can use that Task related list to show.

You can go in list layout and can do dot walk from task table to ritm and bring change request number on the list.

 

Please mark helpful if it is.

Brad Bowman
Kilo Patron
Kilo Patron

Create a new Related List by going to System Definition -> Relationships in the left nav.  Create a new record.  Put whatever you want to appear as the tab title in the Name field.  Applies to table = change_requestQueries from table = sc_task.  Your Query with script will look like this.

(function refineQuery(current, parent) {
	taskArr = [];
	var ritm = new GlideRecord('sc_req_item');
	ritm.addQuery('parent', parent.sys_id);
	ritm.query();
	while(ritm.next()){
		var sctsk = new GlideRecord('sc_task');
		sctsk.addQuery('request_item', ritm.sys_id);
		sctsk.query();
		while(sctsk.next()){
			taskArr.push(sctsk.sys_id.toString());
		}
	}
	current.addQuery('sys_id', 'IN', taskArr.join(','));
})(current, parent);

Now on your Change Request form you can Configure > Related Lists and you will see your new Name in this list.

find_real_file.png

Yeah, use Ankur's one line script instead.  Not sure why that didn't work when I tried it - must have had a typo, but that's all you need in this case.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you need to create custom relationship

Steps

1) Relationships -> Under System Definition

2) Create new

3) Applies to Change Request table

4) Queries from Catalog task table

5) Script as this

(function refineQuery(current, parent) {

	// Add your code here, such as current.addQuery(field, value);
	
	current.addQuery('request_item.parent', parent.sys_id);

})(current, parent);

find_real_file.png

Then add this related list on CHG form by configuring related list

Regards
Ankur

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