PutinFolder method for newly created Web documents

If you're reading this post, you've probably discovered the same problem as me with putting a newly created Web document into a folder via the PutInFolder method on the Web.

The problem is caused by the way Domino handles a newly created document. A new document created with @Command([Compose]) or the ?openform generates a tempory document. You'll receive all the required values--but be aware that some of these values changes when you submit your document, depending on the field type you use.

When you've on your form a computed when composed text field with default value @Text(@DocumentUniqueId). The value of this field shall be changes when submitting the form. The same for @Unique to create an unique key. The PutInFolder method takes a real document and put this in the mentioned folder. The method will create the folder but will never put your posted document into the folder for the simple reason that it doesn't exist anymore. A new notes document is created by Domino.

The only workaround I've found for this feature is to open an existing document. Open it in edit mode and when the user submit it, enable a submit flag. The disadvantage of this is that your database can be populated by a lot of ghost documents. So what you need is to create a little background agent that clean up (delete) the ghost documents based on the submit flag.

Procedure :

1.Create an action button (New document):

dbPath := "/"+@LowerCase(@ReplaceSubstring(@Subset(@DbName; -1); "\":" "; "/":"+"));
@URLOpen( dbPath + "/Document?CreateDocument")

2.On the form add a computed when composed text field (docUnid)


When the user presses the action button. a new document will be created.

3.Open the document in edit mode
To open the newly created document you need to create for that document a WebQuerySave agent.
In this agent you just reopen the document by scripting following code :

If docCurrent.IsNewNote Then
   StrDocUniqueId = docCurrent.DocUnid(0)
   strDbPath = docCurrent.DbPath(0)
   strReturnUrl = "/0/" & strDocUniqueId & "?Editdocument"
   Print "[" & strDbPath & strReturnUrl & "]"
End if

When the user now submit the document you can use the PutInFolder method in the WebQuerySave agent.

Just don't forget to enable a submit flag when the user submit the document. (ex. IsSavedByUserFlag) and to write a background agent based on this field to delete the ghost documents.

Thx to Henry Kaye for the concept.

This was first published in August 2001

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.