Free Service Portal Widget: Related Lists
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2017 10:26 AM
To help contribute back to the community, we're going to try to develop and give away one new widget per month.
For January we have developed the "Related List" widget, which allows you to display related lists on the form page in Service Portal.
Example below from a service catalog request:
To download the widget, it's available on ServicePortal.io: Free Widget of the Month - ServicePortal.io - Service Portal, CMS, and Custom Apps
- Labels:
-
Service Portal
- 17,496 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2017 09:11 AM
for me, it's not showing count in the badge icon like you have in the original post, any thoughts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2017 02:55 PM
<ul class="nav nav-tabs" role="tablist">"data.related_lists" is populate through the server script in the snippet below. I'd suggest logging this variable out (in either server or client script - although client might be easier to debug) to see if the count is actually coming through. If it's there, it should be populated, and it's likely not showing just due to styling.
<li role="presentation" ng-class='{active:$first}' ng-repeat="list in data.related_lists">
<a data-target="#{{list.table}}" aria-controls="{{list.table}}" role="tab" ng-class='{active:$first}' data-toggle="tab">
{{list.label}}
<span class="label label-as-badge label-primary" ng-if="list.count">{{list.count}}</span>
</a>
</li>
</ul>
var f = $sp.getForm(data.table, data.sys_id, data.query);
data.f = f;
data.related_lists = f._related_lists;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2017 07:49 AM
arthurcheung data.f = f; was missing in my widget, I am not sure what else is missing. can you post the whole code for this widget?
EDIT: it's still not working though.
for (var i in data.related_lists) {
var list = data.related_lists[i];
gs.addInfoMessage('RL '+list.count); // I am getting 0 here
var params = {
table: list.table,
filter: list.field+"="+data.sys_id,
view: 'sp',
title: list.label,
show_new: true
};
// object returning count as 0
- Object
- $$hashKey:"object:80"
- count:0
- field:"task"
- label:"CIs Affected"
- plural:"CIs Affected"
- table:"task_ci"
- type:"M2M"
- visible:true
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2017 02:52 PM
Hi Nish,
We have customised the widget for specific use at a client, so I can't post the whole widget.
Also, my suggestion was to help you identify the problem, it wasn't actually the fix. So it only makes sense that it's still not working. You don't actually need data.f, we had added it there for our own purposes.
If you look closer, you'll see where data.related_lists is populated from. The fact that you are getting 0 in the count suggest that you should look at the call to:
$sp.getForm(data.table, data.sys_id, data.query);
Are you passing the right parameters in? If so, it could be a platform bug, in which case, what version of SNOW are you on? On glide-istanbul-09-23-2016__patch6-05-02-2017 this is returning as expected.
EDIT:
I've attached a widget I just created to make testing $sp.getForm easier. Just drop it onto a page and you can run it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2017 06:22 AM
(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;
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,
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";
}
list.widget = $sp.getWidget('widget-data-table', params);
}
})();
can you see anything missing/wrong in above code. arthurcheung
I am on glide-jakarta-05-03-2017__patch0-05-18-2017.