Can you get the UserName From The Role?

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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JaziarAuthor Commented:
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
JaziarAuthor Commented:
I did make ListOfRoles allow Mulitple Values so the selection could just be one Role and not all of them as a string
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

JaziarAuthor Commented:
I fixed the problem - thank you very much
JaziarAuthor Commented:
One last thing is there a way to do a @Name([cn]) on the field in the main form that is displaying the name?
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.