The CreatorCon Call for Content is officially open! Get started here.

Close browser tab when button is clicked

Servicenow Use4
Kilo Guru

Hello everyone!

I have a form button called 'Close'. My requirement is as follows: When the button is clicked, the browser tab should be closed. What scripting should be done for this in the UI Action, can anyone help me with this please?

Thanks in advance!

15 REPLIES 15

@Ankur Bawiskar  Thank you.

 

From the newly opened tab, when I click Save & Close, the page quickly closes, but does not save the record. I have observed that mandatory fields were ignored.

However, if I use the Save & Close button directly from the original browser window tab (not launching a new tab), then mandatory fields are detected. And, when all fields have been filled in, I click Save & Close, it does save, but does not close.

Another odd behavior is the button works on a new record that hasn't been saved. Once the record has been saved, the button no longer works. Curious.

Regards,
Desmo

Hi Ankur,

 

I tried the script and it works. Is possible to save the current record then close the window? I have this requirement.

I tried this, but it does not work. Any suggestions?

function closeWindow(){
current.update();
window.open('','_self').close();

}

 

 

Regards,
Desmo

Willem
Giga Sage
Giga Sage

Use:

window.top.close();

Hello Willem,

Apologies, but that line did not work. Here's what I did:

Onclick: closeWindow()

script:

function closeWindow()

{
window.top.close();

}

Bhagyashri Sort
Kilo Guru

Hi,

Refer below link.

https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/workspace/task/close-...

 

Mark it correct and helpful.

Thanks

Bhagyashri Sorte.