- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 06:56 AM
Closing Record producer OnSubmit() client script using window.top.close(); throws javascript error in browser.
Using - top.window.close(); works fine but shows --
"Leave Site?
Changes you made may not be saved?
Leave Cancel"
How to prevent this message getting displayed?
Solved! Go to Solution.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2022 11:33 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 07:13 AM
You can clear the values of all the fields and then execute close() function. Below is the example:
g_form.clearValue('<variable name>');
top.window.onbeforeunload = null;
top.window.onunload = null;
top.window.location = 'URL for redirection';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 07:42 AM
I donot wish to clear anything as i need the backend record with all values but donot want user to see anything after submit nor want it to redirect to anywhere.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2022 07:54 AM
Try this in the code:
g_form.modified=false;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2022 11:33 AM
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