Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

How to close g_modal window in which I have a record producer; I need to close this g_modal window onsubmit of Record producer.

Dhirendra Singh
Mega Sage

For a Custom scoped application, inside agent workspace via a UI action, i display a g_modal.showframe

function onClick(g_form) {
var premiseId = g_form.getUniqueValue();
var rpId = 'rpid';
g_modal.showFrame({
url: 'sp?id=sc_cat_item&sys_id=' + rpId + '&referrer=' + premiseId,
title: 'Validate Premise Location',
size: 'fw',
height: 600
});
}

Opened Record producer is able to do needful. At OnSubmit() just want to close this modal window. How to achieve it, i have tried window.close(), top.window.close(), destroy etc. no luck yet.

1 ACCEPTED SOLUTION

Dhirendra Singh
Mega Sage

Found the nifty solution --

Followed this post - 

https://blog.jackthomas.io/2019/09/07/servicenow-how-to-close-record-producer-after-submission/

 

Essentially created a UI page in my App scope as helper for all such requirements with only window.close(); in client script.

Called in in producer script as producer.portal_redirect = "ui page end point";

 

This works everywhere, be standalone record producer or RP displayed inside g_modal.showframe

View solution in original post

5 REPLIES 5

It should work, although i dont have access to old customer instance but window.close() has to work.