Manage Learn to apply best practices and optimize your operations.

Process Selected Documents in the Order They Are Sorted in a View

If you have several documents in a view, and you want to perform and action on a select few of them, in the order they appear in the view, what is the best way to go about it?

In the R4 world an agent would process a document collection in the order of their UNID, not in the order they appeared in a view. In R5, the ViewEntry class was added that would allow you to process documents in the order they appeared in a view, but what if you do not want to process ALL the documents in the view, how do you process just a collection of selected documents?

A technique I use a lot is to create a hidden folder named "temp", that is designed with the first column sorted in the same order as the view you are selecting documents from. (example: name or date) Then when the user selects the document this wish to perform some action on, the documents are moved into this folder, they are all placed in a collection, then the collection is acted upon in sorted order. When the agent completes, the document are removed from the hidden folder.


Sub Initialize
' Create a document collection from selected docs
' Move doc collection to a folder
' Process items in the folder as a view entry
' Remove from folder

Dim ws As New NotesUIWorkspace
Dim session As New NotesSession

Set db = session.CurrentDatabase
If (db Is Nothing) Then Goto endofsub
Set dc = db.UnprocessedDocuments ' gets a handle on the documents you selected
Call dc.PutAllInFolder( "temp" ) ' moves those selected documents into a folder
Set view = db.GetView("temp")
Set vc = view.AllEntries ' gets a handle on all the documents in the folder
Set entry = vc.GetFirstEntry()
Set doc = entry.Document
....
....

' place the code for the action you want to take on each document here
...
...
Set entry = vc.GetNextEntry(entry)
If Not (entry Is Nothing) Then
Set doc = entry.Document
End If

endofsub:
' place any wrap up stuff here
Call dc.RemoveAllFromFolder( "temp" )

End Sub

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com'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 ...

SearchDataCenter

SearchContentManagement

Close