- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 02:42 AM
Hello!
I suppose most of you know how UI Action buttons work, but my requirement is quite strange and I have no idea how to deal with it. Here is the situation:
I'm opening any record form on task table. On this form there is a field with a special button (not reference icon). Once it's clicked, a new window appears with another form view. I need it to move some data manually from Description field on form1 to different fields on form2. On this 2nd form I created UI Action button 'Save & Close'. Actually I'm expecting that after clicking this button the record will be updated and then the window will close.
And here is the main problem: it's not possible to close window after the record is updated, because UI Action executes client part of the Script field (onlick function), and after that the server side functions are being executed ( current.update() ). There is no possibility to go back to client side to close this unnecessary window. Any ideas for workaround?
Perhaps invoking specific external Client Script with window.close(); is the solution... Thank you in advance for any suggestion.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 06:30 AM
Yeah it may be a bit of a pain as you'll need to use g_form to get the form values you want to save, pass those values to the script include, and use gliderecord to get and update the record, but I'm not sure there's another way to make it happen.
You might also consider using a GlideModal or GlideDialogWindow instead of the popup browser window to pop open the new form for updates. The purpose of those is really to open a new form allow the user to enter some info, and then save and close it, and it does most of that for you so you don't have to worry about managing browser windows.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 05:58 AM
That is interesting. The only thing I can think of would be to use GlideAjax to manually send all the values back to a script include and do the update from there, and then run the rest of the client side js that closes the window. That way you're doing everything client side and can control the order.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 06:02 AM
I would recommend executing the following code and the end of your client script. The server side scripting should not be affected by this window close action.
window.top.close();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 06:23 AM
Thanks for fast reply. 🙂
Yes, I was also thinking about using GlideAjax, passing there 'current' object, update there the record (I suppose it is possible) and return info about success or failure. Then, after getting the response try to close the window.
@snowstorm, the problem is, that when I try to close window before operation on record, the window will close, but the record will not be updated. And when the record is updated I'm on server side, so it's definitely too late to access the 'window' object.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2018 06:30 AM
Yeah it may be a bit of a pain as you'll need to use g_form to get the form values you want to save, pass those values to the script include, and use gliderecord to get and update the record, but I'm not sure there's another way to make it happen.
You might also consider using a GlideModal or GlideDialogWindow instead of the popup browser window to pop open the new form for updates. The purpose of those is really to open a new form allow the user to enter some info, and then save and close it, and it does most of that for you so you don't have to worry about managing browser windows.