How can i get ritm related catalog task numbers in change form related list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-27-2021 03:19 AM
This RITM contine 4 catalog task record i want that catalog task in related list of change form
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-27-2021 03:37 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-27-2021 03:46 AM
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_request. Queries 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-27-2021 03:47 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-27-2021 03:49 AM
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);
Then add this related list on CHG form by configuring related list
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader