Create a widget that displays a ServiceNow UI page

You can create a widget that displays a ServiceNow UI page. This widget can be added to homepages and dashboards.

Before you begin

Role required: admin

About this task

A UI page is a ServiceNow page that is not a list or a form. Certain UI pages, such as external site widgets or gadgets, may not display properly on a homepage or dashboard.

Procedure

  1. Identify the UI page that you want to create into a widget and note its name.
  2. Navigate to System UI > Widgets and click New.
  3. Enter a Name for the widget. This field defines the first category a user selects when adding the widget to a dashboard or homepage.
  4. Enter the following code, making substitutions as noted below.
    • Widget is the title of the widget. This title appears on the top of the widget when you add it to a dashboard or homepage.
    • widgetname is the name of the UI page from step 1. This field defines the second or subcategory a user selects when adding the widget to a dashboard or homepage.
    function sections() {
        return {
            'Widget': {
                'type': 'widgetname'
            }
        };
    }
    
    function render() {
        var scope = gs.getCurrentScopeName();
        scope = (scope == “rhino.global” ? “” : scope + “_”);
        var page = renderer.getPreference('type');
        return renderer.getRenderedPage(scope + page);
    }
    
    function getEditLink() {
        var scope = gs.getCurrentScopeName();
        scope = (scope == “rhino.global” ? “” : scope + “_”);
        var page = renderer.getPreference('type');
        return "sys_ui_page.do?sysparm_query=name=" + scope + page;
    }
    To learn how to make a UI page without using a framework page template, see the Making a UI page without using the framework page template blog posting by a developer in the ServiceNow Community.