- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2022 02:53 AM
Hi all,
I have a scenario where I have to create Relationship in two tables (Related List). Applies to table is "Case" and Queries from table is "Custom" Table. There is a common reference field in both the table and that refers another table. So how do I compare a reference field from "Case" Table and "Custom" table.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2022 03:37 AM
Hi @Sid_Takali ,
Yes I got it. You have the case table and custom table. custom table the case reference field and case table has the custom table field.
we can display related data on custom table which is using on case and vice versa.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2022 03:35 AM - edited ‎12-27-2022 03:36 AM
Hi @Sid_Takali
Lets say field name on custom table is "u_parent" which refer the case record.
Applies to table [Select the table on which the related list appears] : Case
Queries from table [Select the table from which this related list retrieves data] : Custom
Query with : current.addQuery('u_parent', parent.sys_id.toString()); // here parent means Applies to table
If your question is solved, please close the topic by marking my answer "Accept as Solution". This will help others searching for a similar question and will remove the topic from the unsolved list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2022 03:48 AM
Try with below script.
(function refineQuery(current, parent) {
// Add your code here, such as current.addQuery(field, value);
current.addQuery('common_reference_field_backend_name', parent.getValue('common_reference_field_backend_name'));
})(current, parent);