Service Portal related list widget configuration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 03:56 AM
I tried creating the widget to use related lists on service portal based on this link https://serviceportal.io/downloads/related-list-widget/.
When I tried to configure Service Portal view to show different tabs on the related list, the widget doesn't show me the correct data, it shows same data (data from one table) under all the tabs.
Below is the server script on the widget
(function() {
data.f = {};
data.table = $sp.getParameter("t") || $sp.getParameter("table") || options.table;
data.sys_id = $sp.getParameter("sys_id") || options.sys_id;
data.query = $sp.getParameter("query");
if (!data.table || !data.sys_id)
return;
gs.info('rl:sysid: ' + data.sys_id);
gs.info('rl:table: ' + data.table);
// gs.info('rl:query: ' + data.query);
var f = $sp.getForm(data.table, data.sys_id, data.query);
data.related_lists = f._related_lists;
// gs.info('data.related_lists: ' + data.related_lists);
for (var i in data.related_lists) {
var list = data.related_lists[i];
gs.info('rl:list: ' + list.table);
gs.info('rl:filter: ' + list.field);
var params = {
table: list.table,
filter: list.field+"="+data.sys_id,
//filter: list.definedRelationshipFilter || (list.field + "=" + data.sys_id),
view: 'sp',
title: list.label,
//show_new: true,
};
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";
}
gs.info('rl:page: ' + data.page);
list.widget = $sp.getWidget('widget-data-table', params);
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 04:07 AM
Per the change log, this widget was developed in 2017. It needs a few updates to work on todays releases.
Another thread here offers an update to this one that may still work today.
Alternative option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 05:04 AM
Tried replacing the Client controller as per the shared article but still not working
From This
function($rootScope,$location) {
/* widget controller */
var c = this;
$rootScope.$on('data_table.click', function(event,obj) {
console.log(obj);
var link = {};
link.sys_id = obj.sys_id;
link.table = obj.table;
link.id = c.data.page;
$location.search(link);
})
}
To This
function($rootScope,$location) {
/* widget controller */
var c = this;
$rootScope.$on('data_table.click', function(event,obj) {
console.log(obj);
var link = {};
link.sys_id = obj.sys_id;
link.table = obj.table;
link.id = c.data.page;
// $location.search(link);
if (c.options.page) {
var page = c.options.page;
}
if (!c.options.page) {
var page = "form";
}
location.search = '?id=' + page + '&table=' + link.table + '&sys_id=' + link.sys_id;
})
}