Form Deletion Permission

I know the deletion permission can be set in the ACL, but how to set it based on individual form?

Let say in one database I have 2 forms - form1 & form2. I want to allow userA to delete form1 but not form2.

Is it possible? I also want to have edit/modify permission in the same way.

Subject: re: Form Deletion

If you create a ROLE e.g.[CanDel] in the ACL, you’ll be able to give each person the proper ROLE to either delete or not. In the database script you can decide based on that ROLE, who’ll be able to delete the specified form.

Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)

Editor/reader access you control from the form it self.

Subject: re: re: Form Deletion

Thank you.In case I want to use Querydocumentdelete, how to get the document object? I want to control the deletion base on the form name.

Subject: re: Form Deletion

It will be something like this:

Continue = False

Dim sess As New NotesSession

Dim db As NotesDatabase

Dim ws As New NotesUIWorkspace

Dim Roller As Variant

Dim acl As NotesACL    

Dim entry As NotesACLEntry

Roller = Evaluate("@UserRoles")

Set acl = db.ACL

Set entry = acl.GetEntry( sess.CommonUserName )

If ws.Currentdocument.document.Form(0) = "Form1" Then

	If entry Is Nothing Then

		Forall r In Roller

			If ( r = "[CanDelete]" ) Then

				If entry.IsRoleEnabled( "[CanDelete]" ) Then

					Continue = True

				Else

					Continue = False

					Exit Forall

				End If	

			End If

		End Forall

	End If	

End If

Call ws.ViewRefresh

Subject: re: re: re: Form Deletion

There are 2 problems:

1)The ws.CurrentDocument.Document is a NotesDocument. It doesn’t have Form(0) property. Should I use GetItemValue(“Form”) instead?

  1. Error “Object variable not set” showed up when using ws.CurrentDocument.Document. Here is my code sample:

Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)

Dim session As New NotesSession

Dim db As NotesDatabase	

Set db = session.CurrentDatabase



Dim ws As New NotesUIWorkspace	

Dim uidoc As NotesUIDocument	

Set uidoc = ws.CurrentDocument.Document





Dim doc As NotesDocument	

Set doc = uidoc.Document '<- Error Here!





Continue = False	

End Sub

Thanx.

Subject: re: Form Deletion

A Notes document do always have the FORM field after it’s saved. But the problem in your code is that you try to set a document from a document. Your code should be like this:

Dim session As New NotesSession

Dim db As NotesDatabase

Set db = session.CurrentDatabase

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = ws.CurrentDocument '<---- uidoc

Dim doc As NotesDocument

Set doc = uidoc.Document '<- document from uidoc

if doc.Form(0) = ???

Continue = False

End Sub

Subject: re: Form Deletion

Indeed, that was my typo mistake. However after rectifying it, the “Object variable not set” error still appear when I tried to delete a document from a view.It happened at the line: Set doc = uidoc.Document.

As in my example, I can see only “doc declaration successfully” message pop up when deletion.

Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)

Dim session As New NotesSession

Dim db As NotesDatabase	

Set db = session.CurrentDatabase



Dim ws As New NotesUIWorkspace	

Dim uidoc As NotesUIDocument	

Set uidoc = ws.CurrentDocument



If Isnull(uidoc) Then

Msgbox "uidoc is null"

End If





Dim doc As NotesDocument

Msgbox "doc declaration successfully"



Set doc = uidoc.Document <--Error Here!

Msgbox "set doc successfully"



If doc.Form(0) = "Form1" Then

	Msgbox "Form 1!"

Else

	Msgbox "Not Form 1"	

End If

Subject: re: Form Deletion

My mistake, sorry! But here is a script that works. The Source object returns Documentcollection.

Dim ws As New NotesUIWorkspace

Dim session As New NotesSession

Dim db As NotesDatabase

Dim coll As NotesDocumentCollection

Dim doc, doc2  As NotesDocument

Dim i As Integer

Set db = session.CurrentDatabase

If Source.Documents.Count > 0 Then

	Set coll = Source.Documents

	Set doc = coll.GetFirstDocument 

	For i = 1 To coll.Count

		If Not doc Is Nothing Then

			If doc.Form(0) = "Form1" Then

				Set doc2 = doc          '<--------  take care of the document sequence

				Msgbox "Form 1!"

				Continue = True

			Else

				Set doc2 = doc          '<--------  take care of the document sequence

				Msgbox "Not Form 1"

				Continue = False

			End If

		End If

		If i < coll.Count Then

			Set doc = coll.GetNextDocument(doc2)

		End If

	Next

End If

Call ws.ViewRefresh

Subject: re: re: Form Deletion

awesome. thanks.