Display a UI page from a widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 10:57 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 01:35 PM
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);
}
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 01:37 PM
Hi @Andrew158,
I was able to get it working like below:
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