Fix slow queries caused by NewRocket Related List widget in Service PortalIssue <!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } The third-party widget, NewRocket Related List (nr-related-lists), creates related list components on Service Portal pages by retrieving all related lists from the standard form and displaying them using the default widget-data-table. This widget causes performance issues with Defined Related Lists (those defined in the sys_relationship table). When a view includes a Defined Related List, such as in the sys_relationship table, the widget fails to display records for that list. However, in the background, the widget still queries the entire target table causing performance issues. Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } All releases Cause<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } The widget code retrieves all related lists for the "sp" view of the given table. If no "sp" view exists, it uses the Default view. The code assumes only related lists built from reference fields will be on the view. When a Defined Related List appears on the view, the "list.field" variable becomes "undefined". var f = $sp.getForm(data.table, data.sys_id, data.query); data.related_lists = f._related_lists; for (var i in data.related_lists) { var list = data.related_lists[i]; var params = { table: list.table, filter: list.field+"="+data.sys_id, view: 'sp', title: list.label }; if (options.page) { var page = new GlideRecord('sp_page'); if (page.get(options.page)) data.page = page.getDisplayValue('id'); } if (!data.page) { data.page = "form"; } list.widget = $sp.getWidget('widget-data-table', params); } When the issue occurs, in your Browser Developer tools network tab, you'll see the {filter: "undefined={sys_id}"... in the request Payload: In the localhost logs (also called Node Logs) you may see warnings like:: WARNING *** WARNING *** QueryEventLogger: Invalid query detected, please check logs for details [Unknown field undefined in table {table_name}] While the related list fails to display results, the more serious problem is the resulting slow query. The query runs without a filter, potentially scanning the entire table. This creates significant performance issues, especially for large tables accessed by many users through Service Portal. Resolution<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Option 1: Remove Defined Related Lists To fix this issue, remove any Defined Related Lists from the "sp" view of the affected related list. You may need to create an "sp" view if one doesn't exist. Option 2: Modify the widget code Alternatively, in the NewRocket code, add a protective code check to skip Defined Related Lists when the list.field variable is undefined: For example, consider the following improved code excerpt: var f = $sp.getForm(data.table, data.sys_id, data.query); data.related_lists = f._related_lists; for (var i in data.related_lists) { var list = data.related_lists[i]; // protective fix for Defined Related Lists (names have "REL") that are not supported by this widget if (!list.field) continue; var params = { table: list.table, filter: list.field+"="+data.sys_id, view: 'sp', title: list.label }; if (options.page) { var page = new GlideRecord('sp_page'); if (page.get(options.page)) data.page = page.getDisplayValue('id'); } if (!data.page) { data.page = "form"; } list.widget = $sp.getWidget('widget-data-table', params); } Important This article addresses a third-party widget not created by ServiceNow. The suggested solutions are provided without warranty. ServiceNow cannot guarantee these solutions will work in all environments and does not support implementation or any issues that may arise from these customizations. The code stipulates that NewRocket has provided this code without warranty of any kind. Customers can download and install the widget from serviceportal.io. Related Links<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: #000000; } span { font-size: 12pt; font-family: Lato; color: #000000; } h2 { font-size: 24pt; font-family: Lato; color: black; } h3 { font-size: 18pt; font-family: Lato; color: black; } h4 { font-size: 14pt; font-family: Lato; color: black; } a { font-size: 12pt; font-family: Lato; color: #00718F; } a:hover { font-size: 12pt; color: #024F69; } a:target { font-size: 12pt; color: #032D42; } a:visited { font-size: 12pt; color: #00718f; } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } }