Manage Learn to apply best practices and optimize your operations.

Sort Group Document Contents

Sorts the contents of a group document in alphabetical order by first name. The agent can be run either:
--On a single document
--On selected documents
--On all documents
--On all documents - scheduled

Basically, simply depends upon how you configure the agent. The same script can be easily modified to allow it to sort any multi-value field - the crux of the script is basically the same.

Dim session As New NotesSession
Dim db As NotesDatabase
Dim docs As NotesDocumentCollection
Dim nextdoc As NotesDocument
Dim members As NotesItem
Dim sortlist1() As Variant
Dim sortlist2() As Variant
Dim i, j As Integer
Set db = session.currentdatabase
Set docs = db.unprocesseddocuments
Set nextdoc = docs.GetFirstDocument
Redim sortlist(0)
'process all selected documents in the view
While Not (nextdoc Is Nothing)
Set members = nextdoc.GetFirstItem("Members")
'now read through every username in the members list
Forall n In members.values
Redim Preserve sortlist(i)
While n > sortlist(j) And sortlist(j) <> ""
'j will represent the position in the array where this member name should fit
'now we need to fit this member name into the array and move everything else along by one position
If j <= i And i <> 0 Then
While k > j And k <> 0
sortlist(k) = sortlist(k-1)
sortlist(j) = n
'this member name is not before any other names already processed so add to the end of the array list
'keep track of the number of names in the list - i will keep count of the number of member names processed
sortlist(i) = n
End If
End Forall
Set userlistitem = nextdoc.ReplaceItemValue( "members", sortlist)
userlistitem.IsNames = True
Set nextdoc = docs.GetNextDocument(nextdoc)

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials'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 ...