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

Mark Manders
Mega Patron

u_risk_register is a custom table, so you will have to tell us how these connect. Is the table something containing the CI and the Vendor (I assume not, since that would be an easy list).


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hi Mark,

The Vendor is on table core_company, whilst the CI is on cmdb_ci_business_app table (this is on the Risk form as a reference field)

Ankur Bawiskar
Tera Patron
Tera Patron

@GMoon 

Please share some details on that custom table, what fields are present on that table?

what script did you try so far?

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

Hi Ankur,

I have tried both of these so far:

 

(function refineQuery(current, parent) {
current.addQuery('u_business_application', parent.business.application);
})(current, parent);
 
and
 
(function refineQuery(current, parent) {
current.addQuery('u_assigned_to_vendor', parent.getValue('u_business_application'));
})(current, parent);
 
There are many fields on the custom table, I believe the one to focus on would be the Business Application one (which is the CI essentially)
table: u_risk_register
field: u_business_application