Delete Documents From View On Web

Allow users to delete a document in a web view without having to open the
document. Implement in a 4.5x environment.

When I decided to tackle this problem, I initially came up with a mechanism
that used script to automatically generate an HTML page that looked like a
view, complete with checkboxes next to each document. The thought was that a
user would select the documents that they wanted to delete, hit the delete
button and a script would run to delete the documents on the backend. Without
going into a lot of detail, this solution required the use of the
Request_Content CGI variable, which is only available via version 4.6 and above.

Since we are using version 4.5, I decided to try and create an action that
would at least allow the user to delete one document at a time from the view.

I created a column in each of my views that used the following formula:

DocID := @Text(@DocumentUniqueID);
ViewTitle := @ViewTitle;

"&LTa href=\"DeleteFromView?OpenAgent&UNID=" + DocID) + "&View=" + ViewTitle +
"\" onMouseOver=\"window.status=\'Delete this document\'; return true\">&LTimg
src = \"/icons/vwicn081.gif\" Border=\"0\"></a>"

This creates an HTML link that opens the DeleteFromView agent and passes the
UNID of the document in question and the name of the current view to the
agent. It is using one of the default Domino icons as its image source.

When the user clicks on one of the red x's, it calls the DeleteFromView agent.
The agent is then responsible for stripping off the
UNID of the document and the view from which the user is coming. It then gets
a handle to the document on the backend, deletes it and opens a URL that takes
the user back to the view (which works better than navigating back in the
history, since the view gets called from the server instead of the cache.

I have included the script below, which actually borrows several pieces from
the Domino webmail template for 4.5. You can expand upon this technique to
include security restrictions and the like, but for a quick and simple delete
mechanism, this works pretty well.
Script Author: Chris Blatnick
Date Written: 09/17/99
This script is called from an action in a view and the purpose is to delete the
document corresponding to the link that was clicked. A column
is added to each view which will use this functionality. The column creates an
HTML link that calls the DeleteFromView agent, passing the agent
the UNID of the document and the name of the current view. These values are
parsed out of the Query String CGI variable and are used to delete
the document and return the user to the correct view, respectively.

Example of computed URL from column:
onMouseOver="window.status='Delete this document'; return
true">&LTimg src = "/icons/vwicn081.gif" Border="0"></a>
Modification History

Sub Initialize

Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc, webdoc As NotesDocument
Dim arg0name, arg0, arg1name, arg1 As String

Set db = session.CurrentDatabase
Set doc = session.DocumentContext

'Fetch query string & strip off "OpenAgent". workstr$ is the variable
always containing string currently being manipulated.
QueryString$ = doc.Query_String(0)
openagent$ = "OpenAgent&"
pos% = Instr (QueryString$, openagent$)
If pos% = 0 Then Goto ArgumentError
workstr$ = Right$(QueryString$, Len (QueryString$) - Len(openagent$))

'Strip off the first argument name. Line below is commented out as it is
not needed at this time.
pos% = Instr (workstr$, "=")
'arg0name = Left$ (workstr$, pos% - 1)
workstr$ = Right$ (workstr$, Len (workstr$) - pos%)

'Get the value of the first argument. This should be the UNID for the
document being deleted.
pos% = Instr (workstr$, "&")
arg0 = Left$ (workstr$, pos% - 1)
workstr$ = Right$ (workstr$, Len (workstr$) - pos%)

'Strip of the second argument name. In this case, it should be the 'View'
pos% = Instr (workstr$, "=")
'arg1name = Left$ (workstr$, pos% - 1)
workstr$ = Right$ (workstr$, Len (workstr$) - pos%)

'Get the view from which the delete request was made.
pos% = Instr (workstr$, "&")
arg1 = workstr$

'Get the document to be deleted by its UNID and delete it.
Set webdoc = db.GetDocumentByUNID( arg0 )
Call webdoc.Remove(True)

'Prep for response page
InfoPathPos% = Instr (doc.Path_Info(0), db.FileName)
If InfoPathPos% <> 0 Then
FileAndPath$ = Left$(doc.Path_Info(0), InfoPathPos% + Len
End If

'Return the user to the view from which he/she came. Got lazy here and
hardcoded server.
Print "[http://servername" & FileAndPath$ & arg1 & "?OpenView]"
Exit Sub

Print "An error has occured. Invalid arguments were supplied. Please
contact the Help Desk."
Exit Sub

End Sub

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 ...