In employee center portal we want to add the "My Tickets " as header menu item .And we login user click on "MY tickets" then it will show complete list of task record opened for him example. incident, problem RITM etc.The error message we are recievi

monika27
Tera Contributor

i have the the " MY tickets" menu item in "more" menu item of employee center

script -

// maximum number of entries in this Menu
var max =30;

var t = data;  // shortcut
t.items = [];

// Addition by Paul Austin - EPS to show this menu always. Not funtioning at the moment.
t.showAlways=true;
//

var u = gs.getUser().getID();

 

// use record watchers to tell header when to update dropdown counts
t.record_watchers = [];
t.record_watchers.push({'table':'change_request','filter':'active=true^requested_by=' + u});
t.record_watchers.push({'table':'u_application_defect','filter':'active=true^u_requested_for=' + u});
t.record_watchers.push({'table':'incident','filter':'active=true^caller_id=' + u});
t.record_watchers.push({'table':'sc_req_item','filter':'active=true^requested_for=' + u});
t.record_watchers.push({'table':'problem','filter':'active=true^opened_by=' + u});

 

var st = new GlideRecord('change_request');
if (st.isValid()) {
    st.addActiveQuery();
  st.addQuery('requested_by', gs.getUserID());
  st.orderByDesc('sys_created_on');
  st.setLimit(max);
  st.query();
  while (st.next()) {
    var a = {};
    $sp.getRecordValues(a, st, 'short_description,sys_id,number,sys_updated_on');
    if (st.short_description.nil())
      a.short_description = "(No description)";
    a.__table = st.getTableName();
    a.type = 'record';
    a.sortOrder = st.sys_created_on.getGlideObject().getNumericValue();
    t.items.push(a);
   
     }
}

var z = new GlideRecord('incident');
z.addActiveQuery();
z.addQuery('caller_id', gs.getUserID());
z.orderByDesc('sys_created_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';
  a.sortOrder = z.sys_created_on.getGlideObject().getNumericValue();
  t.items.push(a);

  }

var n = new GlideRecord('u_application_defect');
n.addActiveQuery();
n.addQuery('u_requested_for', gs.getUserID());
n.orderByDesc('sys_created_on');
n.setLimit(max);
n.query();
while (n.next()) {
  var a = {};
  $sp.getRecordValues(a, n, 'short_description,sys_id,number,sys_updated_on');
  if (n.short_description.nil())
    a.short_description = "(No description)";
  a.__table = n.getTableName();
  a.type = 'record';
  a.sortOrder = n.sys_created_on.getGlideObject().getNumericValue();
  t.items.push(a);

  }

var p = new GlideRecord('problem');
p.addActiveQuery();
p.addQuery('opened_by', gs.getUserID());
p.orderByDesc('sys_created_on');
p.setLimit(max);
p.query();
while (p.next()) {
  var a = {};
  $sp.getRecordValues(a, p, 'short_description,sys_id,number,sys_updated_on');
  if (p.short_description.nil())
    a.short_description = "(No description)";
  a.__table = p.getTableName();
  a.type = 'record';
  a.sortOrder = p.sys_created_on.getGlideObject().getNumericValue();
  t.items.push(a);

}

 

var z = new GlideRecord('sc_req_item');
z.addActiveQuery();
z.addQuery('requested_for', gs.getUserID());
z.orderByDesc('sys_created_on');
z.setLimit(max);
z.query();
while (z.next()) {

  var a = {};
  $sp.getRecordValues(a, z, 'sys_id,number,sys_updated_on');
   
    a.short_description = z.cat_item.getDisplayValue() || z.getDisplayValue("short_description");
  a.__table = z.getTableName();
 a.type = 'record';
  a.sortOrder = z.sys_created_on.getGlideObject().getNumericValue();
  t.items.push(a);
 

}

t.items.sort(function(a, b) {
  return b.sortOrder - a.sortOrder;
});

t.count = t.items.length;

var link = {title: gs.getMessage('View all tickets'), type: 'link', href: '?id=my_tickets', items: []};
t.items.unshift(link); // put 'View all requests' first

 

----------------------------------------------------------------------------------------------------------------------------------------

The error message we are recieving on the employee center portal now.

 

4 REPLIES 4

Shruti
Mega Sage
Mega Sage

Hi,

getGlideObject() does not work in scope

Try to create "MY tickets" menu item in Global scope and associate it with parent menu item "More"

 

Susan Britt
Mega Sage
Mega Sage

Hi Monika,

The OOB My Requests that appears in the EC header menu should show all of the task records (e.g., Incident, Change, HR Case, RITM) opened for the logged in user without the need of a custom menu item.  The scripts on this ("Requests") in Activity Configuration read your defined task types setup in Service Catalog > My Request Filter.  

 

 

OOTB Request doesnot conatin all the task based  record. Thats's why we are using tikctes.

You can configure what appears there from the Service Catalog > My Request Filter module. You can add any task type that is missing and the conditions, if needed.