
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2017 08:18 AM
At the header of my Service Portal, I see:
I need this number to also count in records from a custom table. Which widget script do I need to edit to add my custom table?
So the "Requests" count should not say 1, but 6
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2017 08:26 AM
In the nav search, type sp_rectangle_menu_item.list, then search for Label = "Requests"
You'll see the commented text about record watchers. Add a new line with your table and filter to include in the count:
// use record watchers to tell header when to update dropdown counts
t.record_watchers = [];
t.record_watchers.push({'table':'service_task','filter':'active=true^opened_by=' + u});
t.record_watchers.push({'table':'incident','filter':'active=true^caller_id=' + u});
t.record_watchers.push({'table':'sc_request','filter':'active=true^requested_for=' + u});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2022 01:46 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2018 06:44 AM
The click path to get to this file would be:
Service Portal > Menus > Title = "SP Header Menu" > Requests
I added watchers for Changes and Calls:
t.record_watchers.push({'table':'change_request','filter':'active=true^opened_by=' + u});
t.record_watchers.push({'table':'new_call','filter':'caller.sys_id=' + u});
var cr = new GlideRecord('change_request');
cr.addActiveQuery();
cr.addQuery('opened_by', gs.getUserID());
cr.orderByDesc('sys_updated_on');
cr.setLimit(max);
cr.query();
while (cr.next()) {
var a = {};
$sp.getRecordValues(a, cr, 'short_description,sys_id,number,sys_updated_on');
if (cr.short_description.nil())
a.short_description = cr.getDisplayValue("short_description")
a.__table = cr.getTableName();
a.type = 'record';
a.sortOrder = cr.sys_updated_on.getGlideObject().getNumericValue();
t.items.push(a);
}
var call = new GlideRecord('new_call');
call.addActiveQuery();
call.addQuery('caller.sys_id', gs.getUser().getID());
call.orderByDesc('sys_updated_on');
call.setLimit(5);
call.query();
while (call.next()) {
var a = {};
$sp.getRecordValues(a, call, 'short_description,sys_id,number,sys_updated_on');
if (call.short_description.nil())
a.short_description = "(No description)";
a.__table = call.getTableName();
a.type = 'record';
a.sortOrder = call.sys_updated_on.getGlideObject().getNumericValue();
t.items.push(a);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 05:58 AM
Hi, I have a Custom table (u_sample) which is similar to incident and it doesn't extent task table. Users submit records to this table using the portal. I am not able to see these records in "My request " tab in Service portal header, I only see Requests and Incidents.
I added the code as mentioned in the thread, still no luck. Can someone please help me with this.
Code that I modified:
// use record watchers to tell header when to update dropdown counts
t.record_watchers = [];
t.record_watchers.push({'table':'incident','filter':'active=true^caller_id=' + u});
t.record_watchers.push({'table':'sc_request','filter':'active=true^requested_for=' + u});
t.record_watchers.push({'table':'u_sample','filter':'u_user=' + u});
var call = new GlideRecord('u_sample');
call.addActiveQuery();
call.addQuery('u_user', gs.getUserID());
//call.addQuery('u_user.sys_id', gs.getUser().getID()
call.orderByDesc('sys_updated_on');
call.setLimit(max);
call.query();
while (call.next()) {
if (!call.canRead())
continue;
var a = {};
$sp.getRecordValues(a, call, 'sys_id,u_number,sys_updated_on');
if (call.short_description.nil())
a.short_description = "(No description)";
a.__table = call.getTableName();
a.type = 'record';
a.sortOrder = call.sys_updated_on.getGlideObject().getNumericValue();
t.items.push(a);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 10:46 AM
Maybe you just didn't paste it, but there should be a closing curly brace to wrap up that while statement at the bottom:
// use record watchers to tell header when to update dropdown counts
t.record_watchers = [];
t.record_watchers.push({'table':'incident','filter':'active=true^caller_id=' + u});
t.record_watchers.push({'table':'sc_request','filter':'active=true^requested_for=' + u});
t.record_watchers.push({'table':'u_sample','filter':'u_user=' + u});
var sample = new GlideRecord('u_sample');
sample.addActiveQuery();
sample.addQuery('u_user', gs.getUserID());
sample.orderByDesc('sys_updated_on');
sample.setLimit(max);
sample.query();
// use this to debug what is coming out
console.dir(sample);
while (sample.next()) {
if (!sample.canRead())
continue;
var a = {};
$sp.getRecordValues(a, sample, 'sys_id,u_number,sys_updated_on');
if (sample.short_description.nil())
a.short_description = "(No description)";
a.__table = sample.getTableName();
a.type = 'record';
a.sortOrder = sample.sys_updated_on.getGlideObject().getNumericValue();
t.items.push(a);
}
Also add some console dumps so you can debug. I added one above.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 01:44 PM
The above code is just to get those to show up in your nav menu. If you want them to show up in the widgets from your screenshot, you'll need to update those separately.