I Needed to find the people that belonged to a given lotus Notes group. It couldn’t be a simple lookup since other groups can and frequently are also members of a group, so it needed to be be recursive.
Function expandGroupListMembers(GroupName)AsVariant
Dim session AsNewNotesSession Dim db AsNotesDatabase Dim gView AsNotesView Dim memberList AsVariant Dim gDoc AsNotesDocument
Set db = session.CurrentDatabase Dim nab AsNewNotesDatabase(db.Server ,"names.nsf")' this assumes that db is NOT running locally but is a server
Set gView = nab.GetView("($VIMGroups)") Set gDoc = grpsView.GetDocumentByKey( GroupName , True)
If gDoc IsNothingThenExitFunction'could not find this GroupName in view so stop and return empty
memberList = gDoc.GetItemValue("Members") Forall member In memberList Dim subMemberList AsVariant
subMemberList = expandGroupList(member)'see if member is a group and if so get its members IfNotIsempty(subMemberList)Then 'member was a group, now add all its members to list IfIsempty(expandGroupList)Then
expandGroupList = subMemberList Else
expandGroupList = AddArraysEval (expandGroupList, subMemberList) EndIf Else 'member was not a group therefore assume is a person and add to list ' note it could be a server or something else IfIsempty(expandGroupList)Then
expandGroupList = member Else
expandGroupList = AddArraysEval (expandGroupList, member) EndIf
EndIf EndForall
EndFunction
Function AddArraysEval (a1 AsVariant, a2 AsVariant)AsVariant 'from http://www.nsftools.com/tools/lsbook.htm '** add two arrays or scalar values using @Functions Dim session AsNewNotesSession Dim db AsNotesDatabase Dim doc AsNotesDocument Dim var AsVariant Set db = session.CurrentDatabase Set doc = NewNotesDocument(db) Call doc.ReplaceItemValue("a1", a1) Call doc.ReplaceItemValue("a2", a2)
AddArraysEval = Evaluate("a1 : a2", doc) '** clean up the memory we used Set doc = Nothing Set db = Nothing EndFunction
the AddArraysEval is from Julian Robichaux’s very handy LotusScript Book