Notifications

8 views

Description

How to display request items (RITM) instead of Requests (REQ) on Service Portal header menu

Procedure

  1. Navigate to menu item Requests of SP Header Menu:

<Your instance>/nav_to.do?uri=sp_rectangle_menu_item.do?sys_id=ab1d6522875023000f220cf888cb0b32

2. Replace "sc_request" in the following line:
t.record_watchers.push({'table':'sc_request','filter':'active=true^requested_for=' + u});

with "sc_req_item"
t.record_watchers.push({'table':'sc_req_item','filter':'active=true^requested_for=' + u});

3. Comment the following lines in the server script:

/*
var z = new GlideRecord('sc_request');
z.addActiveQuery();
z.addQuery('requested_for', gs.getUserID());
z.orderByDesc('sys_updated_on');
z.setLimit(max);
z.query();
while (z.next()) {
if (!z.canRead())
continue;

var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', z.getUniqueValue());
ritm.query();
if (!ritm.next())
continue;

var a = {};
$sp.getRecordValues(a, z, 'sys_id,number,sys_updated_on');
if (ritm.hasNext()) // there are multiple items for this request
a.short_description = ritm.getRowCount() + ' requested items';
else if (!ritm.canRead()) // only one item, but user cannot see it
continue;
else // one item, and user can see it
a.short_description = ritm.cat_item.getDisplayValue() || ritm.getDisplayValue("short_description");
a.__table = z.getTableName();
a.type = 'request';
a.sortOrder = z.sys_updated_on.getGlideObject().getNumericValue();
t.items.push(a);
}
*/

4. Add the following codes:

var z = new GlideRecord('sc_req_item');
z.addActiveQuery();
z.addQuery('request.requested_for', gs.getUserID());
z.orderByDesc('sys_updated_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_updated_on.getGlideObject().getNumericValue();
t.items.push(a);

}


5. Save the change

Applicable Versions

All releases supporting Service Portal 

Additional Information

https://community.servicenow.com/community?id=community_question&sys_id=15dff6addb58dbc01dcaf3231f961914

Article Information

Last Updated:2019-06-25 13:40:50
Published:2019-06-19