Home > Domino Tips > Developer > LotusScript > List group members from UI doc field
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

List group members from UI doc field


gary cronin
11.24.2004
Rating: -1.83- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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.

    Rate this Tip
    To rate tips, you must be a member of SearchDomino.com.
    Register now to start rating these tips. Log in if you are already a member.




    Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



    RELATED CONTENT
    LotusScript
    LotusScript finds the first occurrence of a string from the right
    Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
    Search Microsoft Active Directory with LotusScript
    Three steps to trap and handle save conflicts with LotusScript
    Troubleshoot agents by displaying LotusScript variables online
    LotusScript sorts lists alphabetically
    LotusScript code rebuilds corrupted busytime.nsf file
    Soft-code item names to facilitate LotusScript management
    LotusScript agent automates selective mail file replication
    LotusScript filters and attaches files to a Notes form

    LotusScript
    LotusScript finds the first occurrence of a string from the right
    Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
    Search Microsoft Active Directory with LotusScript
    Three steps to trap and handle save conflicts with LotusScript
    Troubleshoot agents by displaying LotusScript variables online
    LotusScript sorts lists alphabetically
    Run or restart Notes/Domino agents via text messages
    LotusScript code rebuilds corrupted busytime.nsf file
    Soft-code item names to facilitate LotusScript management
    LotusScript agent automates selective mail file replication

    Lotus Domino Designer
    Setting up a Domino 8.5 XPages example
    An introduction to using XPages in Domino 8.5
    Top 10 Lotus Notes/Domino coding and development tips of 2008
    'Customize this view' options are disabled in Lotus Notes databases
    Stop response documents from showing in a Lotus Notes form
    Set a value in a field existing in another Lotus Notes database
    Display Lotus Notes fields as separate entries in one column
    An introduction to Lotus Domino Designer
    Modifying LotusScript code for date and time handling
    Creating custom Lotus Notes Domino login forms

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary

    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts