Userroles and LotusScript

OK, I’ve been searching all morning through the Help and this forum and still cannot find an answer to my problem.

I want to prevent a user from editing a document if the Status=“COMPLETE”, unless the user has the userrole of [Manager].

What is the easiest way to do this? And where does the code go? Either a LotusScript or @Formula solution will work for me.

I have this code in the QueryModeChange of the form but it doesn’t check the user role or prevent the user from editing the document with a Ctrl-E from the view:

If Not ( source.EditMode ) Then

currentStatus = source.FieldGetText( “Status” )

  If ( currentStatus = "COMPLETE" ) Then

Messagebox ( "You are not authorized to edit a Request with the status of COMPLETE." )

continue = False

  End If

End If

Any help will be greatly appreciated,

Quin

Subject: Userroles and LotusScript

Add the line “exit sub” after “continue = false” to prevent the “ctrl-E” edits.

The example for “QueryAccessRoles” in Notes Designer Help would give you a good place to start to check for the [Manager] role.

Subject: RE: Userroles and LotusScript

The Exit Sub doesn’t work for me when using CTRL-E. Is my code in the right area?

Subject: Userroles and LotusScript

Your are overcomplicating this. When the status is set to “Complete”, reset to authors field (if you are using one) to [Manager]:[AdminRole].

if no readers fields, try a script similar to this:

Dim session as New NotesSession

dim db as NotesDatabase

set db=session.currentDatabase

Dim acl As NotesACL

Set acl = db.ACL

Dim entry As NotesACLEntry

Set entry = acl.GetEntry( session.CommonUserName )

If entry Is Nothing Then

Set entry = acl.GetEntry( session.UserName )

End If

If entry.IsRoleEnabled( “[Manager]” ) Then

continue=true

Else

continue=false

End If

Subject: RE: Userroles and LotusScript

Where would you put this code?Also, no Readers/Authors fields on this form.

Subject: RE: Userroles and LotusScript

Well, there should be. Consider Editor access an anomoly, something most users should never see in applications. Author access andAuthors-type fields will handle af of these who-can-edit-what-when problems easily.

Subject: RE: Userroles and LotusScript

Stan,

I guess I’m not seeing the big picture here. How would this help me if I had an Author field?

Thanks,

Quin

Subject: RE: Userroles and LotusScript

Assuming that no-one had Author access, no-one not listed in the Authors field could edit the document. If all that is in the Authors field is the “[Manager]” role, then you don’t need to worry about coding any events.

Subject: RE: Userroles and LotusScript

The lightbulb just switched on. :slight_smile: Thanks for spelling that out for me.

Subject: Userroles and LotusScript

I guess in case you neeed to Trap the CTRL+E also then QueryMode change will not fire but you either need to write on the QueryOpen or the PostQueryOpen Event of the Form.

Yes, Authors fields is the best approach in case your ACL is allowing that, I mean from the Previous design implications.