Display a UI page from a widget

Andrew158
Giga Guru

Hello everyone,

 

I am trying to create a widget that will open a UI Page. To render the UI page I have the following function in my client controller:

function render(floorid, svgtble, svgvar, rmidvar, roomtble, rmplvar){
	var uiPageName = renderer.getPreferences().get("x_admis_fms_work_AMS_Room_Picker");
	return renderer.getRenderedPage(uiPageName);
}

This code was take directly from the ServiceNow documentation I found here, however when I am getting the error "ReferenceError: renderer is not defined". Does anyone know why this would be or know of a better way to open a UI page from a widget?

2 REPLIES 2

Brad59
Giga Guru

The doc you link references creating a System UI > Widget and not a Service Portal > Widget. The System UI > Widget records do not seem to have a client controller section. I have never used a System UI > Widget personally, I so I do not know what they are for. 

Good thing though is that Service Portal widgets have lots of flexibility. I would just use render a modal and supply an HTML template to the modal. I do lack the context of what will need to be done in the modal though.

 

    c.close = function() {
        c.showModal();
    };

    var instance;
    c.showModal = function() {
        var templateUrl = 'case-close-reason-template.html';
        var size = 'md';

        try {
            var options = {
                size: size,
                scope: $scope,
                backdrop: 'static',
                templateUrl: templateUrl
            };
            instance = $uibModal.open(options);
        } catch (err) {
            console.log(err);
        }
    };

James Chun
Kilo Patron

Hi @Andrew158,

 

I was able to get it working like below:

JamesChun_0-1711398935863.png

 

Can you check the following:

  • The Widget was created in the [sys_widget] table, not the [sp_widget] table
  • Is the Widget created in the global scope?

Also, do you mind sharing the entire code of the widget as well?

 

Cheers