Service portal - Scripted List
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2018 04:28 AM
@Hi All,
I have created a portal for GRC application which is a scoped application of ServiceNow. I have created a new scoped application in which I have created a portal for GRC components.
Everything works fine on the portal except for the Header Menu Items. I have created a menu item which is of type 'Scripted list' and put in the below script but the menu item is never visible on the header.
I have put in logs everywhere and found it to execute properly but not sure why the menu item doesn't appear.
//Maximum number of entries in this menu
var max = 30;
var t = data;
t.items = [];
var u = gs.getUser().getID();
//Use record watchers to tell header when to update dropdown counts
t.record_watchers = [];
t.record_watchers.push({
'table': 'x_qui_abc_evidence_collection',
'filter': 'assigned_to=' + u
});
var z = new GlideRecord('x_qui_abc_evidence_collection');
z.addQuery('assigned_to', gs.getUserID());
z.orderByDesc('sys_updated_on');
z.setLimit(max);
z.query();
while (z.next()) {
var a = {};
$sp.getRecordValues(a, z, 'short_description,sys_id,number,sys_updated_on');
if (z.short_description.nil())
a.short_description = "(No description)";
a.__table = z.getTableName();
a.type = 'record';
t.items.push(a);
}
t.items = t.items.slice(0, max); // only want first 30
t.count = t.items.length;
var link = {
title: gs.getMessage('View all evidences'),
type: 'link',
href: '?id=requests',
items: []
};
t.items.unshift(link); // put 'View all evidences' first
Any ideas dave.slusher ctomasi
- Labels:
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2018 05:24 AM
Hi Aswin,
I have never used this type of list before. Sorry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2018 08:50 AM
I'm not sure but it could be because you don't have a 't' before the 'u' variable.
Can you try:
t.u = gs.getUser().getID();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2018 06:34 AM
HI Aswin,
Are there any results in the GlideRecord query you are running? If not, then the menu item doesn't show up. See Service Portal - Scripted List Widget - How to show it all the time?
I'm also a bit surprised that you didn't run into issues with this given that you're working in a scoped app. There are known issues with this running the scripted list code in a scoped app. See: Service Portal Error: Server Javascript error "$sp" is not defined and Header Menu error in Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2018 10:55 PM
Hi niamccash,
You were correct. This issue was because I was creating a scripted list in a scoped application. Scoped application does not allow the use of '$sp'.
I had to then create the scripted list in global application scope and the issue was resolved.