- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2022 10:57 PM
Just like OOTB "Approval" header menu on the Portal, I would like to set a menu that shows Cases assigned to me with number.
Could someone please advise me on how to create the header menu and what kind of script required?
Best Regards,
Aki
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 12:05 AM
Hi Aki,
Go to Service portal > Menus
Open the Header Menu which you want to create the menu item.
On the new Menu page Select Type as Scripted List
// maximum number of entries in this Menu
var max = 10;
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':'incident','filter':'active=true^assigned_to=' + u});
var z = new GlideRecord('incident');
z.addQuery('assigned_to', u);
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,description');
if (z.short_description.nil())
a.short_description = "(No description)";
a.__table = z.getTableName();
a.type = 'record';
a.__page = 'ticket';
t.items.push(a);
}
var hrcCount = 0;
var hrRec = new GlideAggregate('incident');
hrRec.addQuery('assigned_to', u);
hrRec.addQuery('active','true');
hrRec.addAggregate('COUNT');
hrRec.query();
if(hrRec.next())
{
hrcCount = hrRec.getAggregate('COUNT');
}
t.items.sort(function(a, b) {
return b.sortOrder - a.sortOrder;
});
t.items = t.items.slice(0, max); // only want first 30
t.count = hrcCount;
if(hrcCount == "0")
{
t.count = "0";
}
//var link = {title: gs.getMessage('View All Incidents'), type: 'link', href: '?id=my_requests', items: []};//
//t.items.unshift(link);
Try. something similar to above code it will give drop down menu with record selection
Change the table name and if needed add more conditons.
Try and Let me know
Thanks
Viswa

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2022 11:06 PM
Hello. Go to your portal and open the Header menu record from it. Then scroll down to the related lists - you will see that Approvals is a scripted list. You can duplicate it and change the script in way that it filters the records you want. In your case Cases assigned to me (glide record to the cases table, add query - assigned to me is gs.getUserID()).
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2022 11:12 PM
1.) Go to menu items (sp_instance_menu) table
2.) Choose your CSM menu
3.) Open the menu record in the related list and create a menu item with the name My cases
4.) You can refer to the following sample, the following menu item is created to show "My Groups" in the OOB Service Portal Header menu
a) You can set the table as a case
b.) You can set the filter to show the case records related to you
c.) You can also set an icon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 08:56 AM - edited 10-11-2022 08:56 AM
Hi @Sai Kumar B ,
Thank you for your reply! Following your advice, I could make the header show the menu I wanted.
However, by clicking the menu, the link leads to the "ticket" Page of portal. The Page "ticket" does not have sufficient information, so I would like to make the menu lead to "form" Page. Could you let me know how to customize it to achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 12:05 AM
Hi Aki,
Go to Service portal > Menus
Open the Header Menu which you want to create the menu item.
On the new Menu page Select Type as Scripted List
// maximum number of entries in this Menu
var max = 10;
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':'incident','filter':'active=true^assigned_to=' + u});
var z = new GlideRecord('incident');
z.addQuery('assigned_to', u);
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,description');
if (z.short_description.nil())
a.short_description = "(No description)";
a.__table = z.getTableName();
a.type = 'record';
a.__page = 'ticket';
t.items.push(a);
}
var hrcCount = 0;
var hrRec = new GlideAggregate('incident');
hrRec.addQuery('assigned_to', u);
hrRec.addQuery('active','true');
hrRec.addAggregate('COUNT');
hrRec.query();
if(hrRec.next())
{
hrcCount = hrRec.getAggregate('COUNT');
}
t.items.sort(function(a, b) {
return b.sortOrder - a.sortOrder;
});
t.items = t.items.slice(0, max); // only want first 30
t.count = hrcCount;
if(hrcCount == "0")
{
t.count = "0";
}
//var link = {title: gs.getMessage('View All Incidents'), type: 'link', href: '?id=my_requests', items: []};//
//t.items.unshift(link);
Try. something similar to above code it will give drop down menu with record selection
Change the table name and if needed add more conditons.
Try and Let me know
Thanks
Viswa