Move Documents From Sent view to Folders

I tried to write a simple action for user to move documents from Sent view to another folder then remove the selected documents from Sent view.

tmpFolder := @PickList([Folders]:[Single];“”:“”);

tmpExclude := @If(@IsAvailable(“ExcludeFromView”); ExcludeFromView:“S”; “S”);

@If(tmpFolder = “”; “”;

@Do(@Command([FolderDocuments]; tmpFolder);@SetField(“ExcludeFromView”; tmpExclude)))

The action can add the selected documents to the folder, but only the current selected document is removed from the Sent view. Why?

Subject: Move Documents From Sent view to Folders

Because of the nature of an action: A view action written in formula language can only acces the one currently selected document. To access all currently selected docs from a view action, you need to use LS and db.unprocesseddocuments.

Subject: RE: Move Documents From Sent view to Folders

Thanks for the suggestion. I rewrote the function in script:

Dim ws As New NotesUIWorkspace

Dim db As NotesDatabase

Dim col As NotesDocumentCollection

Dim doc As NotesDocument



Call ws.folder(, True)

Set db = ws.CurrentDatabase.Database

Set col = db.UnprocessedDocuments



For i = 1 To col.Count

	Set doc = col.GetNthDocument(i)

	doc.ExcludeFromView = "S"

	Call doc.Save(True, False)

Next

It works fine, but it is not way to determine if users press Add or Cancel button, when prompted. And the selected documents must remove from Sent View regardless cancel is pressed. How to determine if cancel is pressed and so do nothing? Thanks.

Subject: RE: Move Documents From Sent view to Folders

  1. Don’t use getnthdocument; it’s horribly inefficient, and so is a bad habit to get into. It’s even documented in the getnthdocument help:

"Using GetNthDocument to iterate through a loop is strongly discouraged for performance reasons. See GetDocument, GetFirstDocument, GetLastDocument, GetNextDocument, and GetPrevDocument for the preferred loop structure.

Use this instead:

set doc = col.getfirstdocument

do until doc is nothing

doc.excludefromview = “S”

doc.save true, false

set doc = col.getnextdocument(doc)

loop

  1. To what Add or Cancel buttons are you referring?

Subject: RE: Move Documents From Sent view to Folders

dim uiws as new NotesUIWorkspacecall uiws.folder(, True)

When the uiws.folder(,True) is called, the folder prompt will pop-up for users to pick the folder for selected documents to move to. The popup window has Add or Cancel buttons. If users choice Cancel, then the selected documents should not be moved to folder and stay in the Sent View.

Subject: RE: Move Documents From Sent view to Folders

I’m inferring that you want to know which button was clicked so you know whether your code should go ahead and do the move? It doesn’t work that way: The documentation for this method (correctly) states that when ommitting the first argument, as you are, the dialog box takes care of doing the move or copy, so your code doesn’t have to, and you don’t need to know which button was clicked.

Does that address your issue?

Subject: RE: Move Documents From Sent view to Folders

I understand that. However, since “Sent” is a view instead of folder, and documents stored in the view is controlled by the following select statement:SELECT DeliveredDate = “” & PostedDate != “” & !(@IsMember(“S”; ExcludeFromView))

So, in my agent, I have to know which button the user pressed, then determine if the selected documents are needed to remove from the Sent VIEW.

Subject: RE: Move Documents From Sent view to Folders

Maybe you can use the FolderReferences property and check wether the document has been moved.