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.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
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.
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.