- 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-11-2022 08:58 AM
Hi @U_Viswa ,
Thank you for the sample script! 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, NOT "ticket". 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 09:42 AM
Hello,
Am not sure which table your records are coming from?
Currently if you open the record which page it redirecting? (Not from the new menu,existing behaviour)
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 09:58 AM
Hi Aki,
If you wnat to redirect to "form" page . (i assume page id=form)
Change this line in script from
a._page="ticket";
to
a._page='form';
Thanks
viswa