Refresh the form after adding attachments

balakumar1
Kilo Contributor

Hi,

I attach a documents to a record by clicking the attachment icon. When I close the attachment dialog, I want the form to be reloaded.

Is that possible?

Why I need that: There is a BR on sys_attachment table, which creates some records on the related list of the form which I have open. And only when the form is reloaded, those records in the related list are visible. So, I want the user to know that something is added in the related list when he closes the attachment dialog. That's why a reload of form is needed.

Thanks in advance for your help.

4 REPLIES 4

simonw
Tera Expert

Hi,



I haven't tried this with attachments, but you could try putting a gs.setRedirect GlideSystem - ServiceNow Wiki   in your customised business rule.



Kind regards,



Simon


ghsrikanth
Tera Guru

You can modify the existing attachment macro in such a way, when you close the attachment dialog window, the previous url in the stack will refresh like force refresh.


Its implemented in many javascript applications like closing the dialog window will refresh the parent url -


The attachment macro will be in the below url -


https://instanceName.service-now.com/nav_to.do?uri=sys_ui_macro.do?sys_id=2c43bf710a0a0b39001e825b1e...




Hope it is helpful, feedback is appreciated


Hi Srikanth,



Thanks for the response.


I see that the UI Page called 'attachment' has to be modified. sys_ui_page.do?sys_id=b1b390890a0a0b1e00f6ae8a31ee2697



Here, I want "reloadWindow(window);" to be executed on 'beforeunload' event.


But I want the client script of the UI page to listen to the 'beforeunload' event.



I tried adding the following lines, but it is not listening.... Any idea how to get it working?



Event.observe( window, 'beforeunload', reloadParentForm); // doesn't work


Event.observe( GlideDialogWindow.get(), 'beforeunload', reloadParentForm); // doesn't work


Event.observe( window, 'beforeunload', reloadParentForm, false); // doesn't work



function reloadParentForm() {


    GlideDialogWindow.get().destroy();


    reloadWindow(window);


}


Elena Pomana
Tera Guru

Hello @balakumar1 

 

Did you achieve this? I have a similar requirement now.

 

Thank you,

Elena