This does not seem to work anymore - at least not for me. Here's my script:

 

// maximum number of entries in this Menu
var max = 30;

var count = 0;

var t = data; // shortcut
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':'incident','filter':'active=true^caller_id=' + u +'^ORopened_by=' + u});
t.record_watchers.push({'table':'sc_req_item','filter':'active=true^request.requested_for=' + u});


var z = new GlideRecord('incident');
z.addEncodedQuery('active=true^caller_idDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORopened_byDYNAMIC90d1921e5f510100a9ad2572f2b477fe');
//z.addActiveQuery();
//z.addQuery('caller_id', gs.getUserID());
z.orderByDesc('sys_updated_on');
z.setLimit(max);
z.query();
while (z.next()) {
if (!z.canRead())
continue;

var a = {};
count += 1;
$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';
a.sortOrder = z.sys_updated_on.getGlideObject().getNumericValue();
t.items.push(a);
}

var z = new GlideRecord('sc_req_item');
z.addEncodedQuery('active=true^request.requested_forDYNAMIC90d1921e5f510100a9ad2572f2b477fe^ORrequest.opened_byDYNAMIC90d1921e5f510100a9ad2572f2b477fe');
//z.addActiveQuery();
//z.addQuery('request.requested_for', gs.getUserID());
z.orderByDesc('sys_updated_on');
z.setLimit(max);
z.query();
while (z.next()) {
if (!z.canRead())
continue;

var a = {};
count +=1;
$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';
a.sortOrder = z.sys_updated_on.getGlideObject().getNumericValue();
t.items.push(a);
}

t.items.sort(function(a, b) {
return b.sortOrder - a.sortOrder;
});
t.items = t.items.slice(0, max); // only want first 30
t.count = t.items.length;

if (t.count == 0){
gs.log('count '+t.count + ' length '+t.items.length);
t.count = 'o';
gs.log('count '+t.count + ' length '+t.items.length);
}

var link = {title: gs.getMessage('View all tickets'), type: 'link', href: '?id=my_tickets', items: []};
t.items.unshift(link); // put 'View all requests' first

 

Could it be the way that I'm getting the count that's causing this issue or could it be because of the way some of the other aspects of the portal are configured?