UI Action script (client side) to save record & close the current window.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 05:50 AM
Hi Community,
I have a 'Save & Close' UI Action to save the record & close the current window.
However below code is not working:-
g_form.save();
window.close();
Could anyone please help with the same?
Any response will be appreciated.
Thanks,
Ankita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 06:02 AM
Can you try this:
var myWindow = window.location.href
myWindow.close()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 06:03 AM - edited 10-31-2023 06:06 AM
@Ankita Kolhe Create UI action as below. No need to include onClick function. I tested on incident table and it works.
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 06:26 AM
@Ankita Kolhe have you tried this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 06:09 AM
Keep in mind that the ability to close a browser window from a script may be restricted due to browser security settings. In many modern browsers, pop-ups can only be closed directly if they were opened by the script itself.
Additionally, it is important to use this with caution, as closing a window without the user's permission can be intrusive and is not considered best practice in many scenarios.
Why was this solution used? Maybe we can find an alternative.
If necessary, try using this code:
var currentWindow = window.self;
currentWindow.opener = window.self;
currentWindow.close();
MVP 2025 ✨