To download attachments in an application and also to be able to delete them, the FileDownload control is used on IBM Domino XPages. Unfortunately, this control comes with a little twist. If you click on the trash can icon to delete the attachment, it looks like the file is actually deleted. But the file is not finally deleted until the XPage is saved.

If you leave the XPage after the click on the trash can icon, without saving the document – after all, the attachment disappeared from the view, so why SHOULD you save the document anyway – and open it some time later again, the file is back.


Img. 1: Document including several attachments


Img. 2: Document after clicking the trash can icon of the last attachment


Img. 3: The last attachment is back again after leaving the document without saving and coming back to it afterwards


In order to execute the change, or rather the deletion, directly within the document, it is necessary to add the property setSave(true) to the event handler of the trash can icon. Unfortunately, you cannot do this within the Domino Designer. So a little programming work is needed.

Luckily I have found the appropriate code for most of this work in a discussion comment on stackoverflow by Sven Hasselbach:

Unfortunately, the original code always produced the following error when I used it with Notes 9:


Therefore, I adjusted the source code, so that it works with Notes 8.5.3 and Notes 9 alike. To use it properly you only need to insert it into the BeforeRenderResponse event of the XPage.




            function overrideFileDownloadAction( fDownload ){

                        //Check whether the control exists or not

                        if( fDownload === null )


                        //Call actual function

                        rekOverrideFileDownloadAction( fDownload, fDownload );



*This control iterates through all children of the FileDownload control

*and seeks the event handler


            function rekOverrideFileDownloadAction( component:javax.faces.component.UIOutput,  ){


                                   //Get children of the current element

                                   var children:java.util.List = component.getChildren();

                                   var it:java.util.Iterator = children.iterator();

                                   var curChild:javax.faces.component.UIOutput;

                                   //Loop over all children

                                               while( it.hasNext() ){

                                                         curChild =;

                                                         if( typeof( curChild ) === '' ){

                                                         //Event handler found

                                                         //set setSave to true

                                                         // to automatically save after the event



                                   //Event handler not found, therefore recursive call to investigate the children

                                   rekOverrideFileDownloadAction( curChild , fDownload );





overrideFileDownloadAction( getComponent( 'IDFILEDOWNLOAD' ) );

//IDFILEDOWNLOAD = the ID of the FileDownload control




If the above code is inserted into your XPage, the file is automatically saved after clicking on the trash can icon. The disadvantage of this is that it saves the complete document and not just delete the attachment. Therefore, you have to be careful to ensure that you have not previously changed the value of another field that should not be saved.