Publish a UI page in a dashboard

Stewe Lundin
Mega Guru

Hi!

I'm trying to publish a UI Page as a Widget on a dashboard.

I'm getting;
Security constraints prevent access to requested page
Its a simple UI page writing out Hello World on the screen.
No JavaScript no nothing.
The code for the widget;

function sections() {

      return {

              'widget_name': { 'uiPageName' : 'hello_world'},

      };

}

function render() {

      var uiPageName = renderer.getPreferences().get("uiPageName");

      return renderer.getRenderedPage(uiPageName);

}

function getEditLink() {

      return "sys_ui_page.do?sysparm_query=name=" + renderer.getPreferences().get("uiPageName");

}

I have given the widget one of out public roles, and I'm running this with full admin.


What am I missing.  

10 REPLIES 10

ArTex
Tera Contributor

How to open a UI page in a Widget to be added to a dashboard

Sometimes there are highly customized requirements that request the return of values/variables not part of a table, and as a result, we cannot use them in a report with the OOTB functionalities provided by ServiceNow.

 

In the example I will demonstrate, I need a report with the sum of the sponsoring fees per year. These values are obtained through a script include and do not belong to any variable in the “Sponsoring” table.

Visualization of the sponsoring fee per year in two records, calculated based on three variables from the table (start, end, and fee). The table was generated through a UI macro added to a formatter.

ArTex_0-1743769772434.png

Problem: How can I use the data generated for all records to create a report with the sum of the sponsoring fees per year?

 

Solution: Create a UI page to generate the table with the results of the sum of the sponsoring fees per year, and add it to a widget to be displayed on a dashboard.

 

Result:

ArTex_2-1743769972272.png

 

Development:

UI Page

Objective: create a list/table with the records of the sum of all fees per year.

Note: Other ways to visualize the data can be created, for example, through charts.

ArTex_3-1743770039101.png

Widget

Objective: add the UI Page to a widget to be used in a dashboard.

ArTex_4-1743770113236.png

Dashboard

Now the widget is available and can be added to a dashboard:

ArTex_5-1743770154898.png