Create a button. Paste the following three sections of code behind the button. Note: This button is client LotusScript.
IN THE CLICK EVENT OF THE
BUTTON PASTE THIS CODE:
Dim ws As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc=ws.currentdocument
Dim fName As String
fName= uidoc.FieldGetText
("GroupNameToLookup")
Dim AllNames, tmpName As String
Dim vGrpMembers As Variant
vGrpMembers = GetGroupMembers(fName)
For i = 0 To Ubound(vGrpMembers)
tmpName = Strleft( vGrpMembers(i), "/")
tmpName = Strright ( tmpName , "=" )
AllNames = allnames & i+1 & ") " &
tmpName & Chr$(13)
Next
Messagebox "The member of the group "
& fname & " are as follows:" & Chr$(13)
& AllNames
END OF CODE SECTION ONE
CODE SECTION TWO IS A FUNCTION
Function GetGroupMembers
(strGrp As String) As Variant
On Error Goto LocalErrHandler
Dim Personview As NotesView
Dim key As Variant
Dim Persondoc As NotesDocument
Dim Persondb As notesdatabase
Set Persondb = getNames
Set Personview = Persondb.GetView
( "Groups" )
key = strGrp
Dim iValidDoc As Integer
iValidDoc = 0
GetGroupMembers = True
Set Persondoc = Personview.
GetDocumentByKey(key)
GetGroupMembers =
Persondoc.Members
Exit Function
END OF CODE SECTION TWO
CODE SECTION THREE IS ALSO
A FUNCTION
Function getNames As NotesDatabase
Dim s As New NotesSession
Dim db As NotesDatabase
Set db = s.currentDatabase
Set getNames=New NotesDatabase
("YOUR FULL SERVER NAME","names.nsf")
End Function
MEMBER FEEDBACK TO THIS TIP
Do not use the Groups view, prefer a hidden view such as $Groups (less risk when upgrading to a new version). Also, what about nested groups ?
Pierre B.
******************************************
This seems like a lot of code for something that should be very simple.
I like to create a hidden, multi-field Computed for Display field that uses the group selected in the first field. Then use whatever method required to display the names. (Modify the server as required.) Formula language is usually faster than LotusScript.
@IfError(@DbLookup("":"NoCache"; "":
"names.nsf"; "($VIMGroups)";
GroupName; "Members");
@Return(""));
Where GroupName is the field name holding the group name.
Randy P.
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip exchange by member Gary Cronin. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.