Script to close current window

sunil29
Tera Contributor

Hello All,

Can any one tell me how many ways are there to close the window.

can you provide me the script to close the window.

8 REPLIES 8

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi sunil,

there are a lot of ways, it depends on your need, below some examples:

1) through a UI Action

GlideDialogWindow.get().destroy();

2) through a Business Rule

g_scratchpad.close_window = gs.action.getGlideURI().toString().indexOf('sysparm_close_window=true') != -1;

3) through an OnSubmit Client Script

if(g_scratchpad.close_window){

       g_form.submit();

       window.top.close();

     }

Hope this will help to fit your need.

Please, remember to mark Correct or Helpful if you find my response useful.

Cheers
Alberto

 

Hi.. I used the below code in UI Action script:

GlideDialogWindow.get().destroy();

It redirected me to the last visited page in the same tab.. Is there a way to simply close that tab when the button is clicked?

Omkar Mone
Mega Sage

Hi 

"Window" here refers to which window? Service Portal ?

any form like incident.