Can you get the UserName From The Role?

Posted on 2004-11-30
Last Modified: 2013-12-18
Using Qwaletee suggestion.  I am sure you can see how this works.  Can we make this work in reverse.
I would like a button named Pick Role -> The form underneath has a field that displays the Roles in the ACL or could even look for a specific Role - Example The button would be named Pick DE Role and then the field would be populated with users assigned to the Role DE?  Right now we pick the name and then we get the role, I need to pick the role and get the names.  I really like the way Qwaletee set this up, so I would like to continue with it.

First, add a field to the form called NameFromACL, computed when composed, value ""
Second, add a field called RolesForACLName, allow multiple values, computed when composed, value ""
Third, add a button labeled "ACL Roles" with the following formula:

Next, create a subform.  Copy the same two fields to the subform.
Change the first field (NameFromACL) to type Dialog List, choices frmo ACL, enable refresh fields on keyword change.
Hide the second field.
Then, put the following code in the QueryClose of the subform:
    source.Document.ReplaceItemValue "RolesForACLName" , source.Document.parentDatabase.acl.getEntry(Source.FieldGetText("NameFromACL")).roles
Question by:Jaziar
    LVL 31

    Accepted Solution

    It was very easy to set up the "pick name" field, because thatis built in to Notes.  And it was very easy to set the result field to the vale of all that person's roles, because there is a pretty direct way to request from Notes all the roles assigned to a particular entry.

    There is no built-in list type that says "show a list of ACL roles to choose from."  There is no direct way to say "here's a role, please return a list of names it matches."

    Instead, to get the list of roles in the database, we have to run a simple script... and to use thatin a field list, we have to have that script assign its results to a field, that will then be used for choices.

    And, to find out who has the role, we have to loop over all the ACL entries, then loop over all the roles for that entry to see if there is a match, then record the anme of that entry if there is a match, into a growing list that the script uses internally, and finally at the end, put the script's internal list into the result field.


    In the subform PostOpen, add the following code:
    Source.Document.ReplaceItemValue "ListOfRoles" , Source.Document.ParentDatabase.ACL.Roles

    The first field should now be called RoleFromACL, and the choices should be a formula: ListOfRoles

    Add a field to the top of the form, computed for display, named ListOfRoles, allows multiple values, value formula: ListOfRoles

    Change the result field name from RolesFrALName to NamesForACLRole

    The QueryClose formula is now:

    Dim ACL As NotesACL, entry as NotesACLEntry
    Dim nameList() As String
    Redim nameList(0)
    Set ACL = source.Document.parentDatabase.ACL
    Set entry = ACL.GetFirstEntry()
    Do Until entry is Nothing
        Forall role In entry.Roles
            If role = Source.FieldGetText("RleFromACL") Then
                nameList(Ubound(nameList)) = entry.Name
                Redim Preserve nameList(Ubound(nameList)+1)
                Exit Forall
            End If
        End Forall
        Set entry = ACL.GetNextEntry(entry)
    source.Document.ReplaceItemValue "RolesForACLName" , nameList

    Author Comment

    OK I am getting the SubForm Opened and the List of Roles show up.  In the dialog box I can select ex: [DE] and hit enter.  I then get the error

    Notes Error:  Can not locate field

    Author Comment

    I did make ListOfRoles allow Mulitple Values so the selection could just be one Role and not all of them as a string

    Author Comment

    I fixed the problem - thank you very much

    Author Comment

    One last thing is there a way to do a @Name([cn]) on the field in the main form that is displaying the name?
    LVL 31

    Expert Comment

    Yes.  Any fields with the same name on the main and subforms will "sahre data."  In addition, any other fields on the main form can be used in formulas in the subform.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
    For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now