Return to Previous Window from DialogWindow

Chris M3
Tera Guru

I just finished development on a custom dialog window, and I'm having trouble with where it's going after the user clicks 'Ok' on the dialog window.

 

The dialog window pops up from a UI Action from a Form Link.   If they click cancel, it closes without doing anything as designed.   If they click Ok, a Processing Script is run to make some data updates, and I'd like it to return the user to the same form they were looking at before.   However it's directing them to a full page view of the UI Page with none of the data that was there previously.

 

Below are the relevant lines of code.

 

<g:dialog_buttons_ok_cancel ok="return resetTimers()"/>

 

Client Script

function resetTimers() {

    GlideDialogWindow.get().destroy();

    return true;

}

1 ACCEPTED SOLUTION

Sorry, the last 2 lines should be:



var urlOnStack = GlideSession.get().getStack().bottom();


response.sendRedirect(urlOnStack);



I had shortened it to just "response.sendRedirect(GlideSession.get().getStack().bottom());", which would work, but thought it might be too confusing.   I did not "undo" enough of the changes to get back to the above 2 lines.  


View solution in original post

8 REPLIES 8

Sorry, the last 2 lines should be:



var urlOnStack = GlideSession.get().getStack().bottom();


response.sendRedirect(urlOnStack);



I had shortened it to just "response.sendRedirect(GlideSession.get().getStack().bottom());", which would work, but thought it might be too confusing.   I did not "undo" enough of the changes to get back to the above 2 lines.  


And I should have caught that, but no dice.   GlideSession doesn't exist.. Is this new? we're on Berlin still.



org.mozilla.javascript.EcmaError: "GlideSession" is not defined.


From the wiki:



"


Note: This API call changed in the Calgary release:


  • GlideSession replaces Packages.com.glide.sys.GlideSession

The new script object calls apply to the Calgary release and beyond. For releases prior to Calgary, substitute the packages call as described above. Packages calls are not valid beginning with the Calgary release. For more information, see Scripting API Changes.


"



UI Pages - ServiceNow Wiki


Thanks! It works.   Again, something I should have caught.