Control how attachments are removed

In a previous article I talked about using a combination of checkboxes and a WebQuerySave agent to produce an alternative method of removing attachments from a document. Thus, getting rid of the horrible check-boxes that domino automatically generates:


Whilst that method worked fairly well, I have since learnt of a much easier/better/quicker way to do this.

All you need to do is create your own set of check-boxes that all share the same name: %%Detach.

Easiest way to do this is to use a Computed-Text area (you can't use a field as they don't allow the % character in the name). The formula should be along the lines of:

@If(!@Attachments; @Return(""); "");
"<p>Remove attachments here:<br>" +
@Implode("<input type=\"checkbox\" name=\"%%Detach\" value=\""+@AttachmentNames+"\">"+@AttachmentNames; "<br>");
"<p>View attachments here:<br>" +
@Implode("<a href=\"" + @Text(@DocumentUniqueID) + "/$file/" + @AttachmentNames + "\">"+@AttachmentNames + "</a>"; "<br>"))

What does this do? First thing is to see if there are any attachments on the document. If not then it just returns an empty string (""). Otherwise, it checks if the document is in edit mode. If so, it creates a delete checkbox for each attachment with a value the same as the file's name. If the document is being read it simply creates a set of links that the user can use to open or save the file from.

Now, when the document is submitted, domino takes control of the deletion of all the files that you selected automatically. Isn't it a clever little thing...

Here is an example of this method being used in a database available for download here. Firstly in read mode:


and in edit mode:


How you make it look and where you place the HTML is totally down to you. No longer do you have to suffer the awful way Iris does it ;-) The last thing to do is to hide the "Iris" part. You could use the <noscript> method, but I prefer this one as it is a lot cleaner.


  1. Different Icons for the attachments

    Hello Jake,

    I have read your article about the control of attachments and I was impressed. I also hate the style how domino displays attachments and I've looked for an alternative and found it on your side. Thank you very much. I've integrated your mechanism in an application and it works like a charm.

    Now I have a question. I want to display different symbols before the link of the attachment. For example: If the document has an attachment with the extension '.txt' I want to display the viewicon 'vwicn020.gif'. If the document has an attachment with the extension '.doc' I want to display the Wordicon 'vwicn142.gif'.

    At the moment I have the following code for the computed text field:

    ************************************* tmpASum:=@Text(@Round((@Sum(@AttachmentLengths)/1024);0,01)) + " Kbytes"; tmpALen:=@Text(@Round((@AttachmentLengths/1024);0,01)) + " Kbytes"; tmprepl:= ".html":".htm":".txt":".zip":".exe":".gif":".jpg":".bmp":".doc":".xls":".wav":". mid":".midi"; tmprwith := "vwicn070.gif":"vwicn070.gif":"vwicn020.gif":"vwicn051.gif":"vwicn159.gif":"vwic n013.gif":"vwicn013.gif":"vwicn013.gif":"vwicn142.gif":"vwicn141.gif":"vwicn015. gif":"vwicn015.gif":"vwicn015.gif"; @If(!@Attachments;@Return("");""); @If(@IsDocBeingEdited; "<br><br><table border=1 bgcolor=\"#0000aa\" cellspacing=0 cellpadding=5><tr><td>"+ "<font size=2 face=\"arial\" color=\"#ffffff\">"+ "Attachments l&ouml;schen:"+ "</font><font size=1 color=\"#555555\">"+ @Implode("<table border=0 bgcolor=\"#eaeff0\" width=300 cellpadding=5>"+ "<tr><td><input type=\"checkbox\" name=\"%%Detach\" value=\""+@AttachmentNames+"\">"+ "<font size=2 face=\"verdana\">"+@AttachmentNames+ "<br></td></tr></table>")+ "</td></tr></table>"; "<br><br><table border=1 bgcolor=\"#0000aa\" cellspacing=0 cellpadding=5><tr><td>"+ "<font size=2 face=\"arial\" color=\"#ffffff\">"+ "Attachments ansehen ("+tmpASum+") :"+ "</font><font size=1 color=\"#555555\">"+ @Implode("<table border=0 bgcolor=\"#eaeff0\" width=300 cellpadding=5>"+ "<tr><td width=200>"+ @If(@Contains("." + @Right(@AttachmentNames;"."); @Implode(tmprepl));""; @Replace("." + @Right(@AttachmentNames;"."); tmprepl; "<img src=\"/icons/" + tmprwith + " \"border=0 width=16 height=11 hspace=3>")) + "<a href=\"" + @Text(@DocumentUniqueID) + "/$file/" + @AttachmentNames+"\">"+ "<font size=2 face=\"arial\"><b>[ "+@AttachmentNames+" ]</b></font></a></td>"+ "<td width=10></td>"+ "<td width=150 align=right><font size=1 face=\"verdana\">"+tmpALen+"</font></td><tr></table>")+ "</td></tr></table>") ************************************* This works so far. But I try to find a solution for unrecognised attachments.

    1. Re: Different Icons for the attachments

      Probably out of date now, but I have several gif files in the database, each of which has the name of a file extension.


      an icon representing .gif files is named 'gif' an icon representing .jpg files is named '.jpg' and aliased '.jpe'

      Then I use the following in as part of a formula.

      "<tr><td width=\"10\"><img onerror=\"this.src=\'../***\'\" src=\"../"+@Right(@Text(@AttachmentNames);".")+"\"></td><td width=\"10\"><input type=\"checkbox\" name=\"%%Detach\" value=\""+@AttachmentNames+"\" class=\"line1\"></td><td><a href=\"" + @Text(@DocumentUniqueID) + "/$file/" + @AttachmentNames+ "\">"+@AttachmentNames + "</a></td><td>" + @Text(@Round(@AttachmentLengths/1024)) + " (Kbytes)</td></tr>"

      Note : onerror=\"this.src=\'../***\'\" this javascript makes a default icon appear '***' from the image resources, if no other icon is found.

      Hope this helps if you still needed a way of displaying an icon if none found.

    2. Re: Different Icons for the attachments

      Less sophisticated, but with icon showing for all attachments not referenced.

      @If(!@Attachments; @Return("<tr><td colspan=4>There are no attachments on this document.</td></tr>"); ""); @Implode("<tr><td width=10><img src=/icons/vwicn" + @If( @Right(@AttachmentNames;".")="doc"; "142"; @Right(@AttachmentNames;".")="dot"; "142"; @Right(@AttachmentNames;".")="xls"; "141"; @Right(@AttachmentNames;".")="xlt"; "141"; @Right(@AttachmentNames;".")="txt"; "020"; @Right(@AttachmentNames;".")="zip"; "051"; @Right(@AttachmentNames;".")="exe"; "159"; @Right(@AttachmentNames;".")="gif"; "013"; @Right(@AttachmentNames;".")="jpg"; "013"; @Right(@AttachmentNames;".")="bmp"; "013"; @Right(@AttachmentNames;".")="html"; "070"; @Right(@AttachmentNames;".")="htm"; "070"; @Right(@AttachmentNames;".")="wav"; "015"; "006") + ".gif></td><td></td><td> <a href=\"" + @Text(@DocumentUniqueID) + "/$file/" + @AttachmentNames+ "\">" + @AttachmentNames + "</a></td><td>" + @Text(@Round(@AttachmentLengths/1024)) + " (KB)</td></tr>";@NewLine)

      Hide the rest of this thread

      1. Re: Different Icons for the attachments

        Added some more icons...

        @If(!@Attachments; @Return("<tr><td colspan=4>There are no attachments on this document.</td></tr>"); ""); @Implode("<tr><td width=10><img src=/icons/vwicn" + @If( @Right(@AttachmentNames;".")="doc"; "142"; @Right(@AttachmentNames;".")="dot"; "142"; @Right(@AttachmentNames;".")="xls"; "141"; @Right(@AttachmentNames;".")="xlt"; "141"; @Right(@AttachmentNames;".")="vsd"; "145"; @Right(@AttachmentNames;".")="msg"; "130"; @Right(@AttachmentNames;".")="txt"; "020"; @Right(@AttachmentNames;".")="zip"; "051"; @Right(@AttachmentNames;".")="exe"; "159"; @Right(@AttachmentNames;".")="mdb"; "061"; @Right(@AttachmentNames;".")="gif"; "013"; @Right(@AttachmentNames;".")="jpg"; "013"; @Right(@AttachmentNames;".")="bmp"; "013"; @Right(@AttachmentNames;".")="html"; "070"; @Right(@AttachmentNames;".")="htm"; "070"; @Right(@AttachmentNames;".")="wav"; "015"; "005") + ".gif></td><td></td><td> <a href=\"" + @Text(@DocumentUniqueID) + "/$file/" + @AttachmentNames+ "\">" + @AttachmentNames + "</a></td><td>" + @Text(@Round(@AttachmentLengths/1024)) + " (KB)</td></tr>";@NewLine)

        1. Re: Different Icons for the attachments

          You should use @RightBack(...) instead of @Right(...) because you get uncorrect extensions if a filename includes more than one '.'!

          An example: Filename.something.doc returns "something.doc" instad of just "doc".

          Furthermore, you should use @LowerCase(...) to support also extensions of "Doc", "DOC", dOC" etc.

      2. Re: Different Icons for the attachments

        Is there an easy way of modifying this code to deal with multiple attachments of different types. Ideally still using formula language??

        Thanks. s

        1. Re: Different Icons for the attachments

          Here is a way to show multiple attachments (up to 100, but could be 1000!). I like this, because its an @function that you can tear apart and use in all sorts of situations involving lists of things and extracting things from them.

          What it does is to display nice small icons next to links to the files anywhere on the form, rather than the big ugly ones at the bottom only like we are trying to do in these articles. Actually it splits the collection of attachments in half, so they list in two columns (hence the @modulo). You could easily modify it to show descriptions instead of filenames or include a delete link/icon/checkbox like Jake did.

          In a two cell table put this into a pass through computed text in the left cell: @If(@Attachments; "";@Return("There are no attachments on this document.")); size := @Integer(@Attachments/2)+(@Modulo(@Attachments;2) != 0); num1 := 0:1:2:3:4:5:6:7:8:9; num10p := 10 ** num1; num100 :=(num10p*+num1); exts:="doc":"dot":"xls":"xlt":"txt":"zip":"exe":"mdb":"gif":"jpg":"bmp":"htm":"h tml":"wav":"pdf":"ppt":"hlp":"wav":"swf":"mov":"mpg":"mpeg":"xml":"xsl":"unk"; maps := "wrd":"wrd":"xl":"xl":"txt":"zip":"exe":"mdb":"img":"img":"img":"url":"url":"wav ":"pdf":"ppt":"hlp":"wav":"swf":"mov":"mov":"mov":"xml":"xml":"unk"; unks := @Explode(@Trim(@Repeat("unk ";@Attachments))); nums := @Text(@Subset(num100;@Elements(exts))); att_exts := @MiddleBack(@AttachmentNames;".";10); nms := @Replace(@Replace(@Replace(@Replace(att_exts;exts;nums);att_exts;unks);nums;exts );exts;maps); @Implode( @Subset( "<img src=\"/"+webDbName+"/icon-" + nms + ".gif\"> <a href=\"" + @Text(@DocumentUniqueID) + "/$file/" + @AttachmentNames+ "\">" + @AttachmentNames + "</a> " + @Text(@Round(@AttachmentLengths/1024)) + " (KB)"; size ); "<br/>"+@NewLine )

          Then do the same thing for the right cell with this formula: @If(@Attachments; "";@Return("")); size := (@Integer(@Attachments/2)+(@Modulo(@Attachments;2) != 0)) - @Attachments; @If(size>-1; @Return(""); ""); num1 := 0:1:2:3:4:5:6:7:8:9; num10p := 10 ** num1; num100 :=(num10p*+num1); exts:="doc":"dot":"xls":"xlt":"txt":"zip":"exe":"mdb":"gif":"jpg":"bmp":"htm":"h tml":"wav":"pdf":"ppt":"hlp":"wav":"swf":"mov":"mpg":"mpeg":"xml":"xsl":"unk"; maps := "wrd":"wrd":"xl":"xl":"txt":"zip":"exe":"mdb":"img":"img":"img":"url":"url":"wav ":"pdf":"ppt":"hlp":"wav":"swf":"mov":"mov":"mov":"xml":"xml":"unk"; unks := @Explode(@Trim(@Repeat("unk ";@Attachments))); nums := @Text(@Subset(num100;@Elements(exts))); att_exts := @MiddleBack(@AttachmentNames;".";10); nms := @Replace(@Replace(@Replace(@Replace(att_exts;exts;nums);att_exts;unks);nums;exts );exts;maps); @Implode( @Subset( "<img src=\"/"+webDbName+"/icon-" + nms + ".gif\"> <a href=\"" + @Text(@DocumentUniqueID) + "/$file/" + @AttachmentNames+ "\">" + @AttachmentNames + "</a> " + @Text(@Round(@AttachmentLengths/1024)) + " (KB)"; size ); "<br/>"+@NewLine )

          Then add the computed for display $V2AttachmentOptions field with the value "0" hidden at the top of the form. Also you will need a field named "WebDbName" which is @dbname with the "\" chars changed to "/" (Jake's "DbPath" field). You will also need some image resources for the small icons. I named mine "icon-xxx.gif" where xxx is the file attachment extention listed in the "maps" variable, "pdf":"doc":"txt":"html":"zip" etc. Basically it says "map zip, gzip, z, tar" files to "icon-zip.gif" etc.

          Also, you have to have fileuploads somewhere. I used four. I displayed them in edit mode and hid the above computed texts in read mode. I never wanted to remove attachments, so I didn't build that into it.

          Here is a detailed explanation, at least of the first of the two formulas:

          Check if there are any attachments. If not then emit some nice message @If(@Attachments; "";@Return("There are no attachments on this document."));

          Size is the number of attachments divided by 2, or as close as you can if its an odd number. It’s the number of icons to show in the left column. size := @Integer(@Attachments/2)+(@Modulo(@Attachments;2) != 0);

          Make a list of 100 sequencial numbers from 0 to 99. A couple more lines, and it could be 1000. We will use a subset of this list… The number of total attachments has to be less than the length of this list, so if you expect more than 100 attachments you better change the formula here (and add a large hard drive, a few memory sticks and an disaster recovery plane to your server). Note the use of the permuted ** and *+ operators. num1 := 0:1:2:3:4:5:6:7:8:9; num10p := 10 ** num1; num100 :=(num10p*+num1);

          This is the list of extentions of files that people might attach. If its not one of these, then it will revert to the last one in it, “unk”, so that we can display the questionmark icon. exts:="doc":"dot":"xls":"xlt":"txt":"zip":"exe":"mdb":"gif":"jpg":"bmp":"htm":"h tml":"wav":"pdf":"ppt":"hlp":"wav":"swf":"mov":"mpg":"mpeg":"xml":"xsl":"unk";

          Each of the above extentions needs an icon. “doc” and “dot” are MS-Word files, so they get the mapping “wrd” so that we can later use the icon named “icon- wrd.gif”. Same with “xml” and “xsl”, they get the icon-xml.gif icon. If you have some really weird ones, then make your own here. (“pl”,”pm” for perl?) Depends on what you expect. maps := "wrd":"wrd":"xl":"xl":"txt":"zip":"exe":"mdb":"img":"img":"img":"url":"url":"wav ":"pdf":"ppt":"hlp":"wav":"swf":"mov":"mov":"mov":"xml":"xml":"unk";

          This is a list containing “unk”:”unk”:”unk”… up to the total number of attachments. We will use it in an @replace in a minute. unks := @Explode(@Trim(@Repeat("unk ";@Attachments)));

          This is a sequential list of numbers from 0 to however many attachments there are. We will soon use it to replace known file extentions with them. nums := @Text(@Subset(num100;@Elements(exts)));

          This is the list of the actual extentions that the attachements have. I had to use @middleback, but I forget why. Maybe it was because the filename included the url which had a period in it. Any this works for me, ymmv. Pick another number besides ten, or use @rightback or something. The point is, to get a list of file extentions here. att_exts := @MiddleBack(@AttachmentNames;".";10);

          Here is where we do the replacements. I’ll break it down since there are four of them working from the middle. Replace the the actual file extentions that match the ones we know about with the something that is unique. sequencial numbers are unique, so they fit the bill. If they weren’t, we would never be able to undo it. This makes a list like this: “9”:”pdq”:”blah”:”4”:”ini” basically anything we know about will be set to a number, anything we don’t know about will be left alone. Next, using that list where it matches the original list (and the numbers won’t match anymore) replace the ones we don’t know about with “unk”. Hence the list of “unk”:”unk” etc. Note that @Replace likes lists to be the same size or divine retribution will be yours. This makes a list like this: “9”:”unk”:”unk”:”4”:”unk” Next, we replace the numbers in the list with their equivalent extentions that we know about. “gif”:”unk”:”unk”:”xlt”:”unk” We are now left with a list of extentions that we know all about. (we know about “unk”, its in the list). All we do now is replace them with the mapped names of the icons (the part of the name that counts anyway) and set “nms” equal to it. “img”:”unk”:”unk”:”xl”:”unk” So if you say, for example “icon-“ + nms + “.png” this will be the list “icon-img.png”:”icon-ink.png”:”icon-unk.png”:”icon-xl.png”:”icon-unk.png” which looks like a list of image names, and it is, (except I’m using gifs for some god awful reason, so my line is a little different)

          nms := @Replace(@Replace(@Replace(@Replace(att_exts;exts;nums);att_exts;unks);nums;exts );exts;maps);

          Next, since we are creating computed text, we make such a list, but adding html into it in the right places. Also, since computed text prefers to be one long string, we implode it so that it doesn’t have those weird commas. And since we only want to show the first half of the list, we use @subset, and that “size” variable I made at the beginning.

          @Implode( @Subset(

          Start with the img tag and give it its source attribute. WebDbName is the modified @dbname in a hidden computed for display field at the top. This should look familiar to the example “.png” code above if you strip away the html… "<img src=\"/"+webDbName+"/icon-" + nms + ".gif\"> <a href=\"" + @Text(@DocumentUniqueID) + These and the above line makes the link to the file attachment. You can change all this to run ?openAgent etc to run an agent that will print content-type headers, read binary and write them out etc. "/$file/" + @AttachmentNames+ "\">" + This is the text of the links. It’s got the same number of elements as @attachments, nms etc, so you can add the arrays one for one, no problem. @AttachmentNames + "</a> " + Same thing here, except it’s the size of each attachment @Text(@Round(@AttachmentLengths/1024)) + " (KB)"; Ok, that just created the list of links for the whole shebang, here is where we get the first half of it. The second half is done with the other formula size ); Add to that list of links, a break tag and a newline to keep things neat in the browser and in the html... (don’t use <br/> in emails to notes users. The notes client doesn’t know what to do with it, use <br> instead, and complain a lot to lotus about complying to html standards NS4 doesn’t know what to do with it either… does anyone use that anymore? Aack!). "<br/>"+@NewLine ) And that’s it. Note that the icon is just that, an icon, its not a live link or a delete button, or a “download here” button. It could be, I suppose. The real meat here is the Big @Replace statement preceded by the sequencial number list generator, the list of expected extentions, actual extentions, and maps to the icon filenames.

          Of course, you have to have image resources or some other method for the icons. I hate using vwicoXXX.gif icons because, well, they are gifs, and that’s proprietary (owned by Unisys) and they just look so… 1990s. (back when we all had great jobs because we knew Domino)

          Regards, -Bill Wheaton

  2. Nice

    Hey Jake - Great site, I was just trying to figure out how to do this.


  3. Problem with deleting attachments


    I'm trying to write a cross client(Notes Client and browser) attachment system and have used this article to incorporate the code to delete attachments and it (so almost) works!

    The problem I have occurs in this scenario:- - a user attaches a file in Notes Client into an RTF field and saves the document. - User with web browser edits the document and checks the box to delete the attachment and saves the document. Opening the document in the browser in read mode shows the file has been deleted. Cool - Notes Client user goes into the document and can still see the file attachment in the RTF field. It looks like the file itself has been removed as the attachment has no properties but "residue" is left in the RTF field that doesn't get auto deleted. I'll look into some LotusScript code to delete the attachment from the RTF and see if that works and let you guys know....

    Cheers, Chris.

    1. Well that's just great....

      According to this:-

      http://www.notes.net/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/ee7265887cce110a 852569b200542be4?OpenDocument&Highlight=0,API,attachment,remove

      The $file (file attachment) field and the file icon bitmap in the RTF are 2 separate things. Great! Not.

      Only solution I can think of is to have a separate field to emulate the %%DETACH field but called something else (like ToBeDeleted) so that Notes can't cock up the deletion. Next step is to detach all files to a temp directory on the server file system using the code on codestore.net. Then delete the RTF field. Then re-attach the files to a newly created RTF excluding the filenames in the ToBeDeleted field.

      What an almighty load of rubbish that is! Of course if there is a better way, then please please let me know!

      Cheers, Chris.

  4. thanks for your info

    Thanks for your info regarding file attachments deletion on browser.

    Bye from Italy

  5. attachments

    Thank you for your very good articles and sorry for my bad english. I have a question about displaying attachments nicly in a table with more than one column: sometimes, I have many attachments in my documents and i want to have a dynamic table with changable column for displaying them, could you perhaps help me.

    Thanks a lot

      • avatar
      • MK
      • Thu 19 Dec 2002

      Re: attachments


      this is a nice workout, thanks for your help

  6. attachments

    To Jake and all the guys....thanks a lot...i also used your ideas for a project that i'm working on and it worked..!!!...really appreciate it....thanks again...:P

    1. Re: attachments

      Hi I have an multiple attachments stored on the document in the web.I want to remove all attachments except the recent attachment when i click on the button.

      coud you please help me in that.

      Thanks Chandra.

      Show the rest of this thread

    • avatar
    • laurens
    • Fri 14 Nov 2003

    same thing, but sorting attachments a-z

    two minor improvements to this lovely code:

    1) using R6 @sort code, you can sort the attachments a-z 2) turning the names of the attahments in to links, it is easier to check what the file contains you considering deleting. E.g. you have 5 pictures uploaded, but don't remember which is which. Clicking on the link opens the attachment in a new browser window.

    AS:=@If(!@Attachments; @Return("");@Sort(@AttachmentNames)); @If(!@Attachments; @Return(""); "Select Attachments or Pictures to be deleted:" + @Implode("<input type=\"checkbox\" name=\"%%Detach\" value=\""+AS+"\"><a href=\"" + @Text(@DocumentUniqueID) + "/$file/" + AS + "\" target=\"_blank\">"+AS + "</a>"; "<br>"))

  7. I wan't the attachment placed in a field...


    Could you please help me out here cause I'm stuck. I wan't to: - be able to upload more then one attachment at one time still not use more than one upload control (make a list...). - have the attachments submitted to a Rich text field rather than as v2-attachments.


    Thanks Ove

  8. Sync between web atts and notes


    I really did like the article on managing attachments from the web, clever stuff.

    However, I run into problems when trying to move attachments uploaded from the web to rich-text fields. All seems to work fine from the web, but the rich text field keeps orphaned icons to attachments that already have been removed from the document via the web. Is there any way to correctly synchronize the web actions with the actual storage of the attachments in a rich text field in Notes?



    1. Re: Sync between web atts and notes

      Hi, I'm having the same problem to sync the web action to the notes actions. Can anybody please help me?

      Show the rest of this thread

  9. I can't hide the attachment

    hi I only use one fileupload controler to upload more than one file.and I use a button to add the file url to a multiple value list box .when the document was saved,I used an agent to EmbedObject all the file to a Rich Text Field. when I open the document from the view,the horrible check-boxes that domino automatically generates does not hidden now. I have been searching and experimenting how to fix this, but did not find a solution for this. Hope you have one.

    Thanks in advance all ready,

    yanli wu

    • avatar
    • Caroline
    • Tue 2 Nov 2004

    Automatically deleting existing attachment

    I have a requirement to only have 1 attachment per document, but that the user can change the attachment. I figured that using the delete method described to only delete the existing attachment if a new one is being uploaded was a good plan. I have the following JavaScript in the onSubmit to detect if we are uploading a new attachment, and to write to a field that effectively deletes the existing attachment. However, you have to click on the save button twice for it to work. Any clever refinement ideas?

    var newfile = document.forms[0].NewFile.value; var del; if (newfile =="") { del = ""; } else { start = newfile.lastIndexOf("\\") + 1; end = newfile.length; file_picname = newfile.slice(start,end);

    del = '<input type="checkbox" name="%%Detach" CHECKED value="'+file_picname+'">'+file_picname; alert (del); } document.forms[0].DeleteAttachments.value = del


      • avatar
      • Caroline
      • Tue 2 Nov 2004

      Re: Automatically deleting existing attachment

      Got it!!

      If you only want 1 attachment per doc, and if you want people to override the existing attachment simply by uploading another, here is the plan:

      In the onSubmit, put:

      var newfile = document.forms[0].NewFile.value; // NewFile is the ID of the File Upload Control

      if (newfile !="") { // there is a new file to upload

      existingFile = document.forms[0].FileName.value; // see FileName field below if (existingFile != "") { // remove existing file document.forms[0]["%%Detach"].value= existingFile // see %%Detach field below } } // end if new file is nothing

      Pu this as computed text at the top of the form:

      "[<INPUT TYPE=HIDDEN NAME = \"FileName\" VALUE=\"" + @Text(@AttachmentNames) + "\">]"

      This is so JavaScript can access the existing file attachment name. At the bottom of the form, hidden, put a field called "FileName" so Domino doesn't have kittens when the doc is saved. Make it editable with no default.

      Put in another bit of computed text on the form to define the detach field:

      "[<input type=\"hidden\" name=\"%%Detach\" value=\"\">]"

      Tested on IE6 and Notes5


      Show the rest of this thread

    • avatar
    • Lois
    • Thu 24 Feb 2005


    I used your attachment code and it works great! But my users want a way to put descriptions for each file. Do you know of a way to do this?

  10. Broken in R7?

    It seems this work around has been broken in R7: http://bob-obringer.com/A557B7/blog.nsf/dx/12142005114901DOMNW8.htm

    - Johan http://johankanngard.net

  11. Deleted Attachment

    Is it possible to make a view for deleted attachmebnts.

    1. Re: Deleted Attachment

      How about using the inotes control in your app to do all the file management.


Your Comments


Navigate other articles in the category "Forms"

« Previous Article Next Article »
Buttons with Keyboard Shortcut   Creating a printer friendly page

About This Article

Author: Jake Howlett
Category: Forms
Hat Tip: Sylvain Goutouly
Keywords: attachment; file; remove; detach;


Print Friendly

Let's Get Social

About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »