We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Relationship Related List Script

Gem Edwards
Kilo Sage

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

@Gem Edwards 

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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

16 REPLIES 16

Ehab Pilloor
Mega Sage

Hi @Gem Edwards,

You can try the following:

Applies to table: core_company
Queries from table: u_risk_register

(function refineQuery(current, parent) {
current.addQuery('vendor', current.u_business_application.vendor); //Query dot walk Risk -> CI record -> Vendor
//Use appropriate field names in the query for vendor (core_company record field) and business application (risk register record field).
})(current, parent);

Regards,

Ehab Pilloor

Ratul Arora
Kilo Guru

Hi @Gem Edwards 

You can try - 

Create a new relationship:

  • Name: Risks Related to Vendor CIs

  • Applies to: core_company

  • Queries from: u_risk_register

current.addQuery('u_business_application.vendor', parent.sys_id);

Query from -  parent.sys_id 

 

 

Thanks, Ratul A