Hiding attachments (without noscript tag!)

Jake Howlett, 19 January 2001

Category: Miscellaneous; Keywords: attachment hide

Don't worry it is not the infamous noscript tag method. We all know about that one by now, don't we!? This is a much cleaner way of doing it. I never liked that method anyway, it seems a bit perverse and uses a "trick" to do something that it was never intended to do. At the end of the day it doesn't really hide the attachment, its details are still visible in the source-code.

Here is how you can do it using Domino's own functionality:

  1. Add a hidden, computed for display field to your form
  2. Call it $V2AttachmentOptions.
  3. Set its value depending on what you want to do.
  4. Remove all those nasty <noscript> tags....
What I usually do is set its value using the following formula:

@If(@IsDocBeingEdited; "1"; "0")

This way we can hide the attachments when the document is being read and show them in edit mode, enabling deletion. If you need to link to the attachments when they are hidden, use a Computed-Text area with a formula similar to:

@If(!@Attachments; @Return(""); "");
"View attachments here:<br>" +
@Implode("<a href=\"" + @Text(@DocumentUniqueID) + "/$file/" + @AttachmentNames + "\">"+@AttachmentNames + "</a>"; "<br>")