Security button on Toolbar

Posted on 2007-10-09
Last Modified: 2013-12-18
Have a form I want to add a "security" button to on the toolbar, is it possible to have a toolbar button which would bring up the address book dialog and allow the original creator to add others who can edit the doc. This way the user can manage their own security on the record. How can I control visibility of the button to just the creator, or someone with admin role.  
Question by:jforget1
    LVL 63

    Expert Comment

    There is hide/when for a button so use that with

    @userroles or LS.

    Use an author field, and reader fields to handle this.

    test thoroughly, and use Canonical names !!

    Check the Design Help for security and document locking.

    I hope this helps !


    Author Comment

    But can I create a button and the code to work on the toolbar and populate data down to the "security" access field on the record. I know I should know this, but it is just eluding me at this point.
    LVL 63

    Accepted Solution

    Here is my info on User role access using various types of code.
    This should handle your hide-when issues, assuming that you have a filed that has the Username in it as created or you use the default Authors function. See
    Authors property  in the Design help under the Notesdocument class


    Checking User Roles with Script  based on Userroles  !!!! ~~~

    Axel Matthies
    05 Feb 2001, Rating 4.20 (out of 5)
    The only way in script to check the roles of a user in the IsRoleEnabled function from NotesAclEntry - class. But this function don't work, when the user is member of a group and the the role is enabled for the group.
    I have create a function which checks, whether a role is set for a User even if he is a member of a group. For R 4.6 and above
    Caveats - 1 must have a single NAb, enforced ACL, or the user must have the group in the NAB ( Domain directory ) for the user he is signed in as.

    Example how the function is calling:

    If RoleEnabled("[Admin]") Then
      Messagebox "Role Admin is set"
      Messagebox "Role Admin not set"
    End If


    Function RoleEnabled(sRole As String) As Integer
         Dim vResult As Variant
         vResult = Evaluate(|@IsMember("| & sRole & |"; @UserRoles)|)
         If vResult(0) = 1 Then
              RoleEnabled = 1
              RoleEnabled = 0
         End If  'If vResult(0) = 1
    End Function

    in functions
    v= Evaluate({@If(@IsMember("[GREAT]"; @UserRoles); "1"; "0")})
        If v(0)="1" Then

    You can use stratight forward method available in LS in R5


    Dim workspace As New NotesUIWorkspace
    Dim session As New NotesSession
    Dim uidoc As NotesUIDocument
    Dim acl As NotesACL    
    Dim entry As NotesACLEntry
    Set db = session.CurrentDatabase
    Set acl = db.ACL
    Set entry = acl.GetEntry( session.CommonUserName )
    If entry Is Nothing Then
     Set entry = acl.GetEntry( session.UserName )
    End If
    If entry Is Nothing Then
     Messagebox _
     "No entry for " & session.CommonUserName & _
     " or " & session.UserName,, "No entry"
     Exit Sub
    End If
    If entry.IsRoleEnabled( "[Supervisor]" ) Then
     Set uidoc = workspace.ComposeDocument( "", "approval" )
     Set uidoc = workspace.ComposeDocument( "", "request" )
    End If

    It is better to use what martijn suggested, because then when someone is in the ACL via a group, the user role is checked as well:

    use the following script

    Forall roles in tRoles
      If roles="[spmotion]" Then
         Exit Forall
      End if
    End Forall

    If rolePresent% Then
      Msgbox "Du har ej behörighet att spara dokument"
    End If


    No need to Evaluate anymore (as of 6.5) -- use NotesDatabase.QueryAccessRoles.  group roles  roles for groups
    LVL 31

    Expert Comment

    Yeah, just create a field of type Authors.  In the second tab of the properties box, there is a big mostly empty section called "Choices" which is initially set to none.  Change the NONE dropdown to Use Address dialog for choices.

    That's it.

    Author Comment

    But is there a way to have the button to launch the adress box for the selection on the toolbar, the business owner really wants it there. I am not sure if there is a way in code to simulate a dialog list in a field and then have that data populate to a field on the form.
    LVL 63

    Expert Comment

    Al you need is  a field that is set as an address field, adn normally hidden. Pressing the button should allow editing the field, and bring up an address book.

    I hope this helps !

    Author Comment

    The thing here is placing this button on the toolbar alongside the action buttons, not sure if I can create a button on the action which will populate this security field in this doc.
    LVL 31

    Assisted Solution

    Yeah, you can use @PickList([Name]) or notesUiWorkspace.pickListStrings(0)

    You'll have to include the logic for taking the result and assigning it to the field.  You;ll also have to deal with adds/changes/removes if you allow multiple selection.

    Author Comment

    Hmmm, may just go with a standard field, that seems like a lot of work.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    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…
    Article by: Rob
    Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 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

    11 Experts available now in Live!

    Get 1:1 Help Now