How to set "Cases assigned to me" notification onto the CSM Portal header menu like Approval?

Aki18
Tera Contributor

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?

 

Aki18_0-1665467522318.png

 

Best Regards,

Aki

1 ACCEPTED SOLUTION

U_Viswa
Mega Sage

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);

 

U_Viswa_0-1665471820137.png

 

 

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

 

 

View solution in original post

7 REPLIES 7

Aki18
Tera Contributor

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?  

Aki18_2-1665503807000.png

 

 

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

 

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