I'm using Domino 5. I am trying to avoid opening a form if the user doesn't have a specific role. I need to access the 'role' field from the doc so I have code in the postopen event. However, the continue=false doesn't work. An error message displays, and the form opens anyway. Please help!
Here's the code:
Sub Postopen(Source As Notesuidocument) Dim doc As notesdocument Dim item As notesitem Set doc = source.document Set item=doc.getfirstitem("RoleX") If item.contains("[ CSSUnderwriters]") Then continue=True Elseif item.contains("[ Admin]; [ CSSUnderwriters]") Then continue=True Else Messagebox "You are not authorized to open this form.",,"No Access" continue=False Exit Sub End If End Sub
Continue is not available in the PostOpenEvent. You have two options. First, you can use your code in the PostOpen Event as modified below.
Sub Postopen(Source As Notesuidocument) Dim doc As notesdocument Dim item As notesitem Set doc = source.document Set item=doc.getfirstitem("RoleX") If item.contains("[ CSSUnderwriters]") Then Goto SingleExit Elseif item.contains("[Admin]; [CSSUnderwriters]") Then Goto SingleExit Else Call source.Close Messagebox "You are not authorized to open this form.",,"No Access" End If :SingleExit End Sub
However, you shouldn't even show the document if you don't want the user to open it. You could use your original code in the QueryOpen event so the document is not opened. Continue is available and will function in QueryOpen.
Although both of these methods will keep the document from being opened, it is not a security function and will not prevent people from accessing information in the document.
Do you have comments on this Ask the Expert question and response? Let us know.
Dig Deeper on Lotus Notes Domino Application Development
Related Q&A from Brian Mahoney
Find out what types of calculations can be computed for a column in a Lotus Notes view and the best way to go about it with this expert response. Continue Reading
Find out why you can't use Formula language to include a doclink to a specific Lotus Notes view or database and need to use LotusScript instead. Continue Reading
Discover the reasons behind a Notes/Domino admistrator having trouble with disabled options in the "customize this view" section of his Lotus Notes ... Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.