How to relate one RITM created by another in a report

manybaronesses
Tera Contributor

Goal:

Given 2 sets of REQ/RITM, where one creates the other, relate them in a report and show the Parent of one of them.

 

Problem (short):

REQ/RITM set 1 creates REQ/RITM set 2. Based on set 2, I need to show set 1's Parent, which is an HRC. Alternately, I can see the HRC in an Additional Comment in set 2, but it's buried and used in a sentence and would need to isolate it.

 

Problem (long):

We are creating a REQ for a hardware order as part of a HR Lifecycle Event (aka their laptop order). By nature of how this is designed, this REQ then creates a RITM for the specific computer. Let's call these the "New Hire" REQ and "New Hire" RITM. Now, the creation of the "New Hire" RITM creates a corresponding "Asset" REQ and RITM, which follows our HAM Pro process. 

 

The only reference that we have at the moment that connect the corresponding "New Hire" and "Asset" REQs/RITMs are in the Additional Comments. Note that the Parent of the "Asset" REQ is Empty. 😞

 

In the New Hire RITM, we have this comment:

manybaronesses_1-1705615561501.png

 

In the Asset RITM, we have this comment: 

manybaronesses_0-1705615501622.png

 

In the report that I'm using to provide details on the "Asset" RITMs, I need to find a way to correlate the corresponding HRC from the "New Hire" REQ.

 

For reference, the table I am using is Table: Requested Item [sc_req_item].

 

Any help would be amazing.

 

1 ACCEPTED SOLUTION

Ahana 01
Tera Expert

To relate one Request Item (RITM) created by another in a report, you can use the "Parent" field in the Requested Item table. Here are the steps:

1. Navigate to the "Requested Item [sc_req_item]" table.
2. Create a new report or modify an existing one.
3. In the report configuration, add a condition where "Parent" is the RITM number you want to relate to.
4. Run the report to see all RITMs that are related to the specified RITM.

Please note that the "Parent" field is not populated by default. You need to create a business rule or a script to populate this field when a RITM is created by another RITM.

Here is a sample script to populate the "Parent" field:

javascript
(function executeRule(current, previous /*null when async*/) {
// Get the parent RITM
var parentRITM = new GlideRecord('sc_req_item');
if (parentRITM.get(current.parent)) {
// Set the parent RITM
current.parent = parentRITM.sys_id;
current.update();
}
})(current, previous);


This script should be placed in a Business Rule that triggers on insert or update of a Requested Item.


nowKB.com

For a good and optimistic result, and solving ServiceNow-related issues please visit this website.https://nowkb.com/home
Kindly mark correct and helpful if applicable

View solution in original post

1 REPLY 1

Ahana 01
Tera Expert

To relate one Request Item (RITM) created by another in a report, you can use the "Parent" field in the Requested Item table. Here are the steps:

1. Navigate to the "Requested Item [sc_req_item]" table.
2. Create a new report or modify an existing one.
3. In the report configuration, add a condition where "Parent" is the RITM number you want to relate to.
4. Run the report to see all RITMs that are related to the specified RITM.

Please note that the "Parent" field is not populated by default. You need to create a business rule or a script to populate this field when a RITM is created by another RITM.

Here is a sample script to populate the "Parent" field:

javascript
(function executeRule(current, previous /*null when async*/) {
// Get the parent RITM
var parentRITM = new GlideRecord('sc_req_item');
if (parentRITM.get(current.parent)) {
// Set the parent RITM
current.parent = parentRITM.sys_id;
current.update();
}
})(current, previous);


This script should be placed in a Business Rule that triggers on insert or update of a Requested Item.


nowKB.com

For a good and optimistic result, and solving ServiceNow-related issues please visit this website.https://nowkb.com/home
Kindly mark correct and helpful if applicable