Service Portal related list widget configuration

Community Alums
Not applicable

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.

RJ8_0-1677066864028.png

RJ8_1-1677066889949.png

RJ8_2-1677066904606.png

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);
    }

})();

 

2 REPLIES 2

MattSN
Mega Sage
Mega Sage

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.

https://www.servicenow.com/community/now-platform-forum/free-service-portal-widget-related-lists/m-p...

 

Alternative option

https://www.servicenow.com/community/developer-articles/how-to-create-a-service-portal-tabbed-relate... 

Community Alums
Not applicable

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;
	})

}