Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Scripted Lists for my request not displaying data or counter on menu item

rocio2
Tera Contributor

Hello,

 

I have created a scripted list menu item for my requests. The issue is that the value and the counter is not displaying at all. I do get a list with the number of records but I cannot see the data just a blank list and the counter does not show up. 

The twelve records are there, if I hover the mouse through the list I can see the twelve spaces but the values are not displaying. Also, I am expecting a counter next to Requests with a number 12. How can I fix this.

 

rocio2_0-1698168419307.png


This is the code I used:

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': 'sn_hr_core_case',

'filter': 'active=true^subject_person=' + u

});

var z = new GlideRecord('sn_hr_core_case');

z.addQuery('subject_person', gs.getUserID());

z.addQuery('active', true);

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=my_requests',

items: []

};

t.items.unshift(link); // put 'View all evidences' first



4 REPLIES 4

ChrisBurks
Giga Sage

Hi @rocio2 ,

I notice that the records that are being watched are on the sn_hr_core_case table. If you created this item menu list outside the HR Core scope, it may be a Restricted Caller Access that is blocking the count.

rocio2
Tera Contributor

Hey Chris,

I did try to create the menu item in HR Core scope but that made no difference. The weird thing is that I am experiencing the issue with the ESC portal because if I use that same menu item in the SP portal then the code works. I honestly dont know what is wrong. I even went to the restricted caller access module to see if there was anything I needed to allow and there is nothing that has been requested access. 

 

Thanks,

Rocio

Brian Workman
Tera Contributor

Have you found a solution to this? I'm experiencing the same problem. The same menu on sp works just fine, but not on esc.

Hi @Brian Workman 

 

For me, I literally copid @rocio2 's code posted above without changing anything, pasted it into a menu item record in the HR Core application scope and it worked.

ChrisBurks_0-1746217633082.png