Relationship Related list Restriction

john_davidson
Tera Contributor

I am trying to display all issues(OOB) for a project in a related list on my status form table u_ppm_status with reference field u_project (which references Project)


 

I created the Relationship and I get all issues but want to restrict it to only issues that match the project number.

This fails but still brings back all records.

current.addQuery('u_project', parent.sys_id);

 

Can someone explain the syntax I should be using and where the values come from.

I've read the Relationship Query help post and it is not clicking!

 

applies to PPM Status [u_ppm_status]

Queries from table Issue [issue]

1 ACCEPTED SOLUTION

Mark Stanger
Giga Sage

I believe the 'issue' table references the project table through the 'parent' field in the OOB setup.   If that's the case, and your 'u_project' field is on the 'u_ppm_status' table then I think you would need this for your query.



current.addQuery('parent', parent.u_project.sys_id);



You'll probably also want to make sure that you don't end up matching on empty records by including a second line like this to filter out issues with no relation to a parent.



current.addNotNullQuery('parent');



Check out this SNGuru article for other examples and details.



http://www.servicenowguru.com/system-definition/relationships/defined-related-lists/



If none of this works then post a couple of screenshots of the forms and relationship and I can take a closer look.


View solution in original post

2 REPLIES 2

Mark Stanger
Giga Sage

I believe the 'issue' table references the project table through the 'parent' field in the OOB setup.   If that's the case, and your 'u_project' field is on the 'u_ppm_status' table then I think you would need this for your query.



current.addQuery('parent', parent.u_project.sys_id);



You'll probably also want to make sure that you don't end up matching on empty records by including a second line like this to filter out issues with no relation to a parent.



current.addNotNullQuery('parent');



Check out this SNGuru article for other examples and details.



http://www.servicenowguru.com/system-definition/relationships/defined-related-lists/



If none of this works then post a couple of screenshots of the forms and relationship and I can take a closer look.


Thanks that worked great. I never tried 'parent', !! thanks for your help