QueryOpen event in view

Good day everyone!

What I’d like to do is to prevent the user to open a doc in a view if:

  1. user != AddUserId (of the doc)

  2. user has no roles of “aaAdmin”

Now, I was able to see the ff.codes in Notes Help:

Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim acl As NotesACL

Dim entry As NotesACLEntry



Set db = session.CurrentDatabase

Set acl = db.ACL

Set entry = acl.GetEntry( session.UserName )



If ( entry Is Nothing ) Then

	continue = False

Elseif Not ( entry.IsRoleEnabled( "xxAdmin" ) ) Then 

	continue = False

End If

End Sub

So basically, I can now work on the things I’d like to do, however I got this error: Wrong argument number for event handler.

If it does not work on QueryOpen in view, where else can I put this script for me to add (source.FieldGetText(“AddUserID”)) in the script above?

I just upgraded to win7 OS and my designer is in ver. 8.5

Thank you very much.

Best regards,

OSO

Subject: QueryOpen event in view

The problem is that “Source As NotesUIDocument” is a bit of a fib (if I’m reading your intent correctly). At the QueryOpen event, you don’t actually have a UI document yet, so none of the UI methods (like FieldGetText or GotoField) will work yet. All you have is a stub of a handle, just enough to let you get a few of the properties of the object like the Document object object behind the UIDocument. You won’t actually have a working UIDocument until the PostOpen event - but you CAN use Source.Document.GetItemValues().

Subject: QueryOpen event in view

Have you used the debugger to see what line you get the error on? If so, would you mind posting that information?

If you post code, and there is an error message, you should always indicate what line it happens on, and the value(s) of any variables used on that line.