How to relate multiple change request records to a single RITM?

ArpitaVK
Tera Expert

Hello

Currently, in the related list of RITM, related change records are displayed. When I open the change the records, the corresponding RITM should be displayed in the change record's related list. For that, I have configured a BR:

Table: change_request

When to run: after insert, update

Script:

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var parentSysId = current.parent;

    var ritmRec = new GlideRecord('sc_req_item');

    ritmRec.get(parentSysId);

    ritmRec.parent = current.sys_id;

    ritmRec.update();

})(current, previous);
 
What is happening is, the corresponding RITM is shown only on the latest change record added in the related list of RITM. If we open previously added change records in the related list of RITM, even though the parent is populated with that RITM number, the RITM record is not present in its related list. 
One of solutions that was suggested for this is to create M2M relationship. But can it be created for existing related list instead of adding a new related list?
1 ACCEPTED SOLUTION

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @ArpitaVK 

 

What is happening is, the corresponding RITM is shown only on the latest change record added in the related list of RITM. If we open previously added change records in the related list of RITM, even though the parent is populated with that RITM number, the RITM record is not present in its related list. 
Atul: This is what expected behaviour and by design, bcz it is  1-1 table not parent and child relationship.
One of solutions that was suggested for this is to create M2M relationship. But can it be created for existing related list instead of adding a new related list?
Atul: I recommend create new M2M table and with new list, so that it will not impact the upgrades.
*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

View solution in original post

9 REPLIES 9

Hi @ArpitaVK when you create a change from RITM, you need to update parent field on RITM table to change request sysid as well, then the RITM will be shown under change request related list.

As of now your updating parent field only on change request hence it is not showing.

 

so you would need after insert BR on change request table

script:

    var gr = new GlideRecord('sc_req_item');
    gr.addQuery('sys_id',current.parent);
    gr.query();
    while(gr.next())
    {
        gr.parent = current.sys_id; // update chg sysid to parent field on ritm
        gr.update();
    }

 

HarishKM_0-1711696148773.pngHarishKM_1-1711696156525.png

 

Regards
Harish

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @ArpitaVK 

 

What is happening is, the corresponding RITM is shown only on the latest change record added in the related list of RITM. If we open previously added change records in the related list of RITM, even though the parent is populated with that RITM number, the RITM record is not present in its related list. 
Atul: This is what expected behaviour and by design, bcz it is  1-1 table not parent and child relationship.
One of solutions that was suggested for this is to create M2M relationship. But can it be created for existing related list instead of adding a new related list?
Atul: I recommend create new M2M table and with new list, so that it will not impact the upgrades.
*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hello @Dr Atul G- LNG ,

If I create a M2M table, do I still need to use BR that I have written?

No, this is what M2M do. Please check OOTB Inc- Prb - change table. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Pushpanjali
Tera Contributor

@ArpitaVK 

 

There is a Out Of The Box/Baseline Related list available on the Change Request table. The query that this Related List is using is the Parent field: parent=<sys_id/GUID for the change record>^.

If Parent (reference field) is not the link between your objects then you need to map what the link is, is it another field or an m2m table.

 

Try this.

 

Please like or mark correct/Helpful based on the impact of the response.

 

Thanks & Regards,

Pushpanjali