Manage Learn to apply best practices and optimize your operations.

List group members from UI doc field

You can retrieve a list of users in a group from the Domino directory based on a field value in an open document and present it in a message box to a user.

View member feedback to this tip.

You can retrieve a list of users in a group from the Domino directory based on a field value in an open document and present it in a message box to a user. Here's how:

  1. Create a new form.
  2. Create an editable dialog list field called "GroupNameTolookup."
  3. In Designer, enter the following formula on the second tab of the field properties. Also set the "Choices" to "Use formula for choices"
    FullServerAdd:="SERVERNAME";
    Filename:="names.nsf";
    Server:=@Left(FullServerAdd;"/");
    
    @DbColumn("":"NoCache";Server : 
    Filename; "Groups";2) END OF FORMULA
    
  4. 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.

This was last published in November 2004

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

SearchExchange

SearchContentManagement

Close