Querydocumentdelete Code

I have this code that prevents deleting documents based on Access level. It is in the Querydocumentdelete in the Database Script.However, I want it to apply to only documents that use two forms “Summer” and “Winter”.

I added "If doc.form(0) = “Summer” And level <5 Then…

but it does not work. The whole code is below. Any ideas? Thanks.

Sub Querydocumentdelete(Source As NotesUIDatabase, Continue As Variant)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim acl As NotesACL

Dim i As Integer

Dim entry As NotesACLEntry

Dim level As Integer ’ ACL level

Dim c As NotesDocumentCollection ’ Collection of Deleted Documents to be processed

Dim doc As NotesDocument ’ Current doc being deleted

Dim item As NotesItem ’ Authors field on document

Dim f As String

Dim ami As Integer ’ Success or Failure integer

’ Get User

Dim user As String

user = session.UserName

’ Get current ACL for user

Set db = session.CurrentDatabase

Set acl = db.acl

If acl Is Nothing Then

’ If acl is nothing then the person has no access to the database and is only in because of public documents

Continue=False

MessageBox( “Your access level does not allow you to delete documents.” )

Exit Sub

End If

Set entry = acl.GetEntry( user)

level = entry.level

’ If ACL level less than author…

If level <5 Then

Continue=False

MessageBox( “Your access level does not allow you to delete documents.” )

Exit Sub

End If

’ If ACL delete documents checkbox is not selected

If entry.CanDeleteDocuments=False Then

Continue=False

MessageBox( “Your access level does not include the check box to delete documents.” )

Exit Sub

End If

’ If ACL level is manager…

If level >5 Then

Continue=True

GoTo SkipToEnd

End If

SkipToEnd:

Exit Sub

End Sub

Subject: What do you see when you run the code in debug mode?

Step through the code, see what happens and where the performance of the code is different from what you expect.

Subject: Show us the code that doesn’t work

I see your declaration for doc, but I don’t see you assigning it or checking the value with an If statement, so this cannot be the right code.

-rich

Subject: Querydocumentdelete Code

Pardon my ignorance, but why aren’t you using NotesDatabase.QueryAccessPrivileges() instead of going to the ACL entries? Surely most users are gaining access through group membership and won’t be separately listed in the ACL by name at all. The delete permission check would then be

Dim userPrivileges As Long

userPrivileges = db.queryaccessprivileges(user)

If ((userPrivileges And DBACL_DELETE_DOCUMENTS) = DBACL_DELETE_DOCUMENTS) Then

'user has delete permission

Subject: If it was me

It would be because I never knew about that method!

I try and just sort through the LS class references every once in a while to look for stuff I’ve not used before. I never noticed the QueryAccess… stuff.

Thanks for pointing that out!

Subject: RE: If it was me

You’re welcome, Doug. And I’ll be the first to admit that a lot of this stuff was easier to pick up if you were glued to the beta forums back in the day – a couple of times every day somebody would stumble across something really cool and we’d all be rushing away to play with it for a while, then trading stories. (It kind of helped to be the “new technology evaluation” guy too. I can’t imagine everybody got a half a day of play time for months on end at work.)

Subject: RE: If it was me

Stan,

I’m actually very lucky. My work (since about '95/'96) has been to be the Notes guy at my place of employment. As such, I have a fair amount of freedom to experiment and learn. It would be great to be in something like the beta forums, but I get pretty close as is.

The biggest thing I have to guard against is getting complacent and NOT spending a bit of time just poking at the help file. I have enough legacy code now that a new app pretty much turns into a scavenging exercise instead of doing blue sky/clean slate design; getting the app out seems more important than being clever.