Relationship Related List Script

GMoon
Tera Guru

Hi all,

I am working a on a requirement whereby I have to add a related list to our Vendor form, showing what Risks have been raised again Vendor CI's. The Relationship is as follows and currently brings back all Risks:

 

Applies to table: core_company
Queries from table: u_risk_register

 

Our CI's are held on a table named - cmdb_ci_business_app. I am having a challenge in getting the correct script in order to do this, could someone assist on this please?

 

1 ACCEPTED SOLUTION

@GMoon 

can you try this

(function refineQuery(current, parent) {
current.addQuery('u_business_application.vendor', parent.sys_id);
})(current, parent);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

16 REPLIES 16

Please let me know what information I can get screenshots of to assist further.

@GMoon 

can you try this

(function refineQuery(current, parent) {
current.addQuery('u_business_application.vendor', parent.sys_id);
})(current, parent);

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

This did it Ankur, thank you for your time and support.

@GMoon 

Glad to help.

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

fzm
Giga Contributor

 

To show only the Risks related to Vendor's CIs (cmdb_ci_business_app), make sure your filter connects the Risk’s CI to the Vendor.

Try this condition in your related list filter:

 

pgsql
CopyEdit
Assuming cmdb_ci on u_risk_register points to cmdb_ci_business_app, and that table has a vendor field linking to core_company, this should work.