Manage Learn to apply best practices and optimize your operations.

Delete file attachments on the Web

Learn how to delete file attachments via the Internet.

This tip allows you to delete several files attachments included in a rich text item. You can use it with the tips "Insert various files attachments on the Web."

This tip works only on NT and Linux server.

The name of the database is "NameBase.nsf".

You need Two Forms and a view:
- the first form is the default form used by the document (Name = DefaultForm).
- the second form is used for deleting t>he files (Name = DeleteForm).

The DefaultForm is composed by : -yours fields,
-a Rich text field which name is "RTFiles"
-and a Computed Field which name is "IDDOC" with the @DocumentUniqueID of the document.

In the DefaultForm, you must create an action "Delete Files" which the JavaScript code is:

 var wintab; var id = document.forms[0].IDDOC.value; wintab ='/NameBase.nsf/DeleteForm?openform&IDDOC=' +id,'','top=150,left=350,toolbar=no,location=no,directories=no, status=no,menubar=no,scrollbars=no,resizable=no,width=420,height=180'); wintab.focus();

This action opens a new window with the form DeleteForm, and in the Query_String, you have the Id of the document in which you want delete the file attachments.

In the DeleteForm, you must create:
- a Field Query_String = Query_String,
- a computed Field with the name "IDDOC" and the code is @Right(Query_String;"&IDDOC=")
- a field SaveOptions with the value "0".
- a multivaluated list field named "DelFiles" which the formula selection is
res := @DbLookup("":"NoCache";"":"";"(ID)";iddoc;2);@If(@IsError(res) | res =""; ""; res);

DelFiles is used for the selection of the files that the user want delete.

In the WebQuerySave event of the DeleteForm, you will put :


And the code for the A-Delete agent is :

 Dim s As NotesSession Dim db As notesdatabase Set s = New NotesSession Set db = s.currentDataBase Dim contdoc As notesdocument Set contdoc = s.DocumentContext Dim view As notesview Dim doc As notesdocument Set view=db.getview("(ID)") Call view.refresh() Set doc = view.getdocumentbykey(contdoc.iddoc(0)) '********** Delete all the files selected**** Dim delfiles As notesitem Set delfiles=contdoc.getfirstitem("DelFiles") Dim rtitem As Variant Set rtitem = doc.GetFirstItem( "RTFiles" ) Dim object As Variant Forall o In delfiles.values If ( rtitem.Type = RICHTEXT ) Then Set object = rtitem.GetEmbeddedObject(o) Call object.Remove Call doc.Save( True, True ) End If End Forall '*********Refresh Document Principal and close window ******** Dim javascript As String javascript ="<script>window.opener.document.location.href=" & """ javascript:_doClick('Refresh',this,null,null)""" & ";window.close()</script>" Print javascript

This agent will delete the files selected with the "DelFiles" Field and refresh the current document.

Dig Deeper on Domino Resources - Part 3

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...