Create one header menu named as "Incident" which will display the count of incidents assigned to the logged-in user. In the header menu of the service portal, I wanted to show the number of incident counts.

Rushikesh5
Giga Guru

Hi All,

Can you please help me with this

Create one header menu named as "Incident" which will display the count of incidents assigned to the logged-in user.

In the header menu of the service portal, I wanted to show the number of incident counts.

 

 

Thanks in advance

1 ACCEPTED SOLUTION

data.items=[]; // Array to be displayed when clicked on menu
data.count=0; // Indicates number of records

var incGr = new GlideRecord('incident');
incGr.addQuery('caller_id',gs.getUserID())
incGr.query();
while(incGr.next()){
var obj={};
obj.title=incGr.getValue('number');
obj.type='link';
obj.href='/sp?id=ticket&table=incident&sys_id='+incGr.getUniqueValue();
data.items.push(obj);
data.count++;

}

 

use the above script in scripted list that will work

 

View solution in original post

11 REPLIES 11

Thameem Ansari
Giga Guru
Giga Guru

Hello there.

 

Create a menu item with type as Filter List and add the condition as I added in the below screenshot

find_real_file.png

after that you can see the count of logged in users as below

find_real_file.png

 

Please mark it as Correct/Helpful If my answer is helpful in any way,

Best regards,

Thameem

Hi Rushikesh,

 

Please mark it as Correct and close the thread if that answers your question.

Thanks, Mate for ur efforts I tried this and it's working as well.

But my requirement is to do this by using Scripting.

can u please help me with this its urgent.

 

Thanks

 

 

if you want to do this using script then change the menu type as scripted list..

 

i have added a sample scripted list for approvals below you change it as per your requirement 

// only show 30 in header menu dropdown
var max = 30;

var t = data;
t.items = [];
t.count = 0;

var u = getMyApprovals();

// use record watchers to tell header when to update dropdown counts
t.record_watchers = [];
t.record_watchers.push({'table':'sysapproval_approver','filter':'approverIN' + u.toString() + '^state=requested'});

var z = new GlideRecord('sysapproval_approver');
z.addQuery("approver", u);
z.addQuery("state", "requested");
z.orderByDesc('sys_updated_on');
z.setLimit(max);
z.query();

var link = {};
link.title = gs.getMessage('View all approvals');
link.type = 'link';
link.href = '?id=approvals';
link.items = [];
t.items.push(link);

while (z.next()) {
  var a = {};
	
  a.short_description = rec.short_description + "";
  if (rec.getRecordClassName() == "sc_request") {
    var items = new GlideRecord("sc_req_item");
    items.addQuery("request", rec.getUniqueValue());
    items.query();
    if (items.getRowCount() > 1)
      a.short_description = items.getRowCount() + " requested items";
    else if (items.getRowCount() == 1) {
      items.next();
      a.short_description = items.getValue("short_description");
    }
  }
  $sp.getRecordValues(a, z, 'sys_id,sys_updated_on');
  a.number = rec.getDisplayValue();
  a.__table = z.getRecordClassName();
  a.type = 'approval';
  t.items.push(a);
  t.count++;
}