Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

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:
@DialogBox("ACLRolePicker")

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
0
Jaziar
Asked:
Jaziar
  • 4
  • 2
1 Solution
 
qwaleteeCommented:
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.

Ready?


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

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)
Loop
source.Document.ReplaceItemValue "RolesForACLName" , nameList
0
 
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
0
 
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
JaziarAuthor Commented:
I fixed the problem - thank you very much
0
 
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?
0
 
qwaleteeCommented:
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.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now