Notifications

609 views

Modifying the page associated to a Scripted List Menu Items in Service Portal 



Overview


Since the scripted list menu items are meant to be dynamic the Page field in the Menu Items are not honored. However, you could add a __page object while generating your list.

 

Adding page object to scripted list


Here is an example of how to modify this functionality in an OOB Request Menu Item: 

  1. Navigate to https://yourInstance.service-now.com/sp_rectangle_menu_item.do?sys_id=7c686d00d7200200a9ad1e173e24d4e9
  2. Part of the OOB script populating the incident items using Glide Record query in addition the page object __page
    var z = new GlideRecord('incident');
    z.addActiveQuery();
    z.addQuery('caller_id', gs.getUserID());
    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');
    if (z.short_description.nil())
    a.short_description = "(No description)";
    a.__table = z.getTableName();
    a.type = 'record';
    a.__page = 'form'; // __page should be string value of the page ID you would like to redirect
    a.sortOrder = z.sys_updated_on.getGlideObject().getNumericValue();
    t.items.push(a);
    }

Note: For this to work, The type of the menu item should always be set record 

Additional Information:

The HTML code for displaying using spDropdownTreeTemplate Angular Template used by the header Menu Widget.

This angular template can be found here https://yourInstance.service-now.com/sp_ng_template.do?sys_id=492127b05b301200e39fc7ad31f91a50

Article Information

Last Updated:2017-12-28 07:00:23
Published:2017-12-28