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,515 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2019 11:19 AM
Hey so what did you have to do to include the _ library? I found that as of Madrid, Servicenow includes two versions of underscore for studio. Did you still have to add the gs.include statement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2019 11:28 AM
I found my issue. Servicenow has their underscore libraries not in global scope. Adding one to global worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2019 12:45 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2019 12:51 PM
I think I found that you can name it underscore and replace the _ in the script with it.
/***include the underscore library so things work ***/
gs.include('underscore');
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.f = f;
data.related_lists = f._related_lists;
/** Snippe to add the related list when from a defined relationship **/
if (underscore(data.related_lists).where({"type": "REL"}).length > 0) {
data.related_lists = underscore(data.related_lists).map(function (item) {
if (item.type === 'REL') {
item.definedRelationshipFilter = extractDefinedRelationshipsQuery(item.apply_to, item.apply_to_sys_id, item.table, item.relationship_id);
}
return item;
});
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2022 12:03 AM
Hi Arthur,
I am trying to use this widget in Rome version and as suggested by you I have created a script include named "underscore-min.js and renamed it "_".
I am not sure if I need to call this script include in server side widget.
But I getting below error. Could you pls help me out where I am going wrong
Here is the snipped of the server side