To pull related lists related list in notification

Poorva Bhawsar
Mega Sage

Hi Community,

I want to pull related list's related list in the notification. Notification is on kb_knowledge table.

I have kb_knowledge_base table record, under that u_kb_template_business_impact_assessment_template table records are there.

Under u_kb_template_business_impact_assessment_template this table record, affected products i.e. m2m_kb_ci table records are there.

I want to pull affected products records in my notification which is on kb_knowledge table. 

How can i do it.

 

I have written one email script but its not working.

var gr = new GlideRecord("m2m_kb_ci");
    gr.addQuery('cmdb_ci', current.parent.sys_id);
    gr.query();
    while (gr.next()) {
        template.print("Affected Products:", gr.getValue('cmdb_ci'));
    }
2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Poorva Bhawsar 

if you have reference field in related table which points to main table, you can fetch the information

Do this

1) notification is on kb_knowledge, so you know the knowledge base associated to this KB

2) get that KB base and query u_kb_template_business_impact_assessment_template with this as parent, fetch all records

3) then query m2m_kb_ci with all the records you received in step 2 and iterate and print

please start from your side

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

Hi,

 

I am able to pull affected products in my notification.

 

Here is my script:

 

var gr = new GlideRecord("m2m_kb_ci");
gr.addQuery("kb_knowledge", current.sys_id);
gr.query();
while (gr.next()) {
template.print(gr.getDisplayValue('cmdb_ci'));
}

 

I just want comma separated values in the affected products. Currently its printing abcxyz, i want it to be abc,xyz. I tried splitting it but its not working.