How do I display a reference field based on the related list from another reference field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2016 03:46 PM
I have created a many to many table between locations (cmn_location) and a configuration item we call Branch Office (u_cmdb_ci_branch_office).
Each location can have more than 1 branch associated with it in the related lists.
I have a catalog request where I have the user select the location.
I then want to display only those branches that are in the related list associated to that location.
I have tried 2 dozen different ways very unsuccessfully.
Can someone please tell me exactly what I need to do.
Thank you in advance for your help.
Regards,
Stacy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2016 11:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2016 12:01 PM
Based on this statement "Each location can have more than 1 branch associated with it" you should not need a M2M table. You just need a reference field on the "u_cmdb_ci_branch_office" to "cmn_location". We do the same thing between a custom "Regions" table and "Location"
Then you just use a ref qualifier to the branch records where the location is equal to the selected location.
If I misunderstood and each branch can also have more than one location please ignore.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2016 12:03 PM
Hello Stacy, for a condition based on dot-walking you would have been able to use a reference qualifier. But because it's an M2M which you can't dot-walk, you would have to create advanced filter condition with scripting. You would need something like the following.
1) Create a javascript function like getBranchesForLocation(location)
2) This would take the location id and query against your M2M table and get you the list of branch ids.
Then, you can define an "Advanced Reference Qualifier" on the branch catalog variable. See http://wiki.servicenow.com/index.php?title=Reference_Qualifiers#Advanced_Reference_Qualifier_Example for an example of this type of advanced reference qualifier that's supported not just for Service Catalog variables, but really at the platform level for your regular table fields.