Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Show Portal Page/Widget in a UI Page (GlideModal/Dialog)

Janel
Tera Guru

I'm doing the typical example of a UI Action + GlideDialogWindow scenario.  Click button, under some conditions show a popup window, user clicks a few things, record gets saved, do some action, etc. etc.  The usual.

  • Instead of using a UI page for my popup and having to deal with jelly, is it possible to use a portal page with a widget AND still interact with the current form?

I've seen a lot of topics about showing a UI Page in a portal page, but very little about a portal page in a UI page.  Here are a couple of things I've stumbled across and gave a go.

Why not save the record and then open the UI page?

That doesn't seem to be a thing.  I have never successfully been able to save a record and then have a GlideDialogWindow/Modal open.  May as well just redirect at that point, which kind of defeats the purpose of a popup.  Unless... I set a user token (getSession) in the UI Action and launched it with an onLoad script if the user token was set.  That may look very misleading to the user.  Showing the record was saved then asking for more information and having to save the record again.

Why not embed the portal page in an iframe on a UI page?

That way gets me about 80% of the way there.  I can pass properties from the UI Action (using setPreference) to the UI Page (using RP.getWindowProperties().get()) and to the Portal page/widget via the URI (using sysparm_things) and grab everything I need to via the widget's server script.

The problem with this method is that the portal page/widget cannot interact with the form it was opened with and I do not see a way for the portal widget to be able to pass any information back to the UI page to perform any sort of handling with it.  Like the iframe suggests, it is truly standalone as if I just redirected the user to a new page.  That means if the current form is dirty there won't be any way to save the record with any user updates previous to clicking the UI action.  Even closing the DialogWindow/Modal from the widget doesn't seem possible.

  • Is there a way to interact with the DialogWindow/Modal from a portal widget in an iframe?
  • Even better, is there a way to interact with the current form, from a portal widget in a UI page in a DialogWindow/Modal?
4 REPLIES 4

Aidan Wardman
Mega Guru

To my knowledge there is currently no way of doing this.

However ServiceNow appears to be forever improving, so it may be a watch this space sort of problem.

Vivek Verma
Kilo Sage
Kilo Sage

Here you go,

 

Show widget on UI 16

Thanks for sharing. This is pretty cool!

I saw the comment about passing values *to* the widget, but still nothing about passing data out from the widget.

Joseph Gabriel
Tera Contributor

Yes, it is possible to access a GlideWindow/GlideModal dialog and its parameters from a widget in the scenario described.

 

Example:

Showing the dialog from the UI platform:

var dialog = new GlideModal("portal_page_container");
dialog.setTitle('Create Jira Ticket');
dialog.setPreference('sysparm_portal_page_id', "some_portal_page");
dialog.setPreference('sysparm_ok', okHandler);
dialog.render();


function okHandler(result){
    alert("ok() called with result=" + result);
}

 

Inside the Portal widget:

// The widget may be running inside the nav frame or not, so look for GlideModal in two places.
var glideModal = top.GlideModal || top.frames[0].GlideModal;

// get ref to dialog by specifying the ui page that its hosting
var dialog = glideModal.prototype.get("portal_page_container");

// get dialog setting (in this example it is a function/callback reference)
var ok = dialog.getPreference('sysparm_ok');
ok("passed");

// if you need to close from within the widget:
dialog.destroy();