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

3 REPLIES 3

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

Hi,
The link do the website doesnt work anymore. Can you please explain the solution you used?

@Zmud follow as per the solution above or below->

 

1) Create a UI page in your app scope or global if need for platform. In its client script only put window.close();
This is a helper ui page which can be used everywhere for all such requirements.

2) Call it in Record producer script as

producer.portal_redirect = "ui page end point";

**ui page end point is url for your ui page exactly like setredirecturl.

 

Solution explanation - >

record producer scripts process server side post submit. so the last line should be set for redirection and this UI page once redirected, it loads with its client script calling it to close.