• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

Security button on Toolbar

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.  
0
jforget1
Asked:
jforget1
  • 4
  • 3
  • 2
2 Solutions
 
SysExpertCommented:
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 !


0
 
jforget1Author Commented:
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.
0
 
SysExpertCommented:
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"
Else
  Messagebox "Role Admin not set"
End If

Code

Function RoleEnabled(sRole As String) As Integer
     
     Dim vResult As Variant
     
     vResult = Evaluate(|@IsMember("| & sRole & |"; @UserRoles)|)
     
     If vResult(0) = 1 Then
          RoleEnabled = 1
     Else
          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

Example:

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" )
Else
 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

rolePresent%=False
tRoles=Evaluate("@UserRoles")
Forall roles in tRoles
  If roles="[spmotion]" Then
     rolePresent%=True
     Exit Forall
  End if
End Forall

If rolePresent% Then
  Continue=False
  Msgbox "Du har ej behörighet att spara dokument"
End If
http://oldlook.experts-exchange.com/Applications/Email/Lotus_Notes/Q_10967761.html?query=user+role&searchType=topic


also

No need to Evaluate anymore (as of 6.5) -- use NotesDatabase.QueryAccessRoles.  group roles  roles for groups
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
qwaleteeCommented:
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.
0
 
jforget1Author Commented:
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.
0
 
SysExpertCommented:
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 !
0
 
jforget1Author Commented:
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.
0
 
qwaleteeCommented:
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.
0
 
jforget1Author Commented:
Hmmm, may just go with a standard field, that seems like a lot of work.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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