What to do after deleting a document

Jake Howlett, 25 April 2001

Category: Forms; Keywords: delete redirect head

What do you do after a user has deleted a document. One option is to do nothing and let Domino return the message "Document Deleted" and then let the user work out what to do next. Not a good idea. I'm going to try and describe a preferrable alternative to this.

Using the Notes client a user would be used to deleting a document and then being returned to the view they were in when the document was opened. After all, do they really want to see a message telling them what they know they just did. This article is going to show how you can return the user to a view (or any URL you like for that matter) after they've deleted a document.

Creating a delete document link

In the browser we can use a hotspot with the @Command([EditClear]) formula to create a link to delete a document. The problem with this link is that we have no control over it. We are going to have to generate the link ourselves. I describe how to do this in more depth in this article. The difference here is that we need to add a little bit to the end. The URL we are going to create is going to have a query string parameter something like:


Notice we have used the URL-Encoded version of ? (%3F) so as not to confuse domino as to which bit is the query string.

So to create the above link using Computed-Text the formula would be:

@If(@IsNewDoc; ""; "<a href=\"" + @Text(@DocumentUniqueID) + "?DeleteDocument&NavigateTo=../Appointments%3FOpenView\">Delete Document...</a>")

You could also use a combination of @Formulae in order to compute a value for the URL to navigate to that depends on some value in the document.

Creating the redirect form

Here we are going to make use of the $$ReturnDocumentDeleted form from the article I mentioned above. When a document is deleted domino checks for this form and, if it exists, displays it to the user. We are going to use this form to redirect them to the required URL. This is going to use a method I discussed in this article that uses the meta-tags to do a redirect.

In the HTML Head Contents for your $$ReturnDocumentDeleted form place the following formula:

pos:=@Member( "NavigateTo"; ArgNames );
url:=@If( pos>0; @Subset(@Subset(ArgValues; pos); -1); @Return("") );
"<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;URL=/" + url + "\">"

Before you can get this formula to work you will need to do this to get the ArgNames and ArgValues fields on your form.

The beauty of this approach is that you have the option of whether or not to redirect the user. If there is no NavigateTo parameter in the URL then the form will simply display and you can use this to display some standard message about the document having been deleted. When you do want to redirect you just stick the URL on the end of the query string...