Prevent Cut to delete documnet in the Embedded view

Hello all,

Please help with solving the followin problem:

I want to prevent of using Edit → Cut to delete document from the embedded view in the form.

I tried to write script for the QueryDocumentDelete in the Database Resourse, but without success.

Thanks in advance,

Aleksandr

Subject: Prevent Cut to delete documnet in the Embedded view

Hi Aleksandr,

I’ll qualify this in that it’s quick, and I didn’t REALLY test it (in a frameset or on a server), so you may need to put in some error traps, etc. Also, fill in the right view and/or form name.

Offhand, I usually don’t allow users to delete anything, so I never give them delete permission to the database. If they want to delete they have to mash a button that marks the form for deletion, and an agent will act on the collection at periodic times - either archiving, or removing.

Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)

Dim dbcollection As NotesDocumentCollection	

Dim ws As New NotesUIWorkspace

Dim uiview As NotesUIView

Set uiview = ws.CurrentView

Dim str_vName As String

If Not uiview Is Nothing Then

	str_vName = uiview.ViewName

	Msgbox "This is the current View: " + str_vName ,,"Debug"

Else

	'Use this to trap a particular form that may be open

	Set doc= ws.currentdocument.Document

	If Not doc Is Nothing Then

		str_vName = doc.Form(0)

	End If	

End If



If str_vName = "" Then

	'Unremark this for debugging purposes

	'Msgbox "Unable to get a handle on the view or form",,"Debug"

	continue = True

	Exit Sub

End If



Select Case Ucase(str_vName)

Case Ucase("Embedded View Name"), Ucase("Form Name")

	Msgbox "Sorry, deleting documents in " + str_vName + "  is not permitted",,"Cannot Delete"		

	Continue = False

Case Else

	Continue = True

End Select

End Sub

Subject: Re: Prevent Cut to delete documnet in the Embedded view

Marylin, thanks for the reply

I check Querydocumentdelete event more carefully and found that it works only on the server - if user create local replica of the database, he still can delete documents and replicate changes on the server. Is it possible to prevent it?

Subject: RE: Re: Prevent Cut to delete documnet in the Embedded view

Odd, because I tested on a local copy :slight_smile: (Not web)

Here is support note:

http://www-1.ibm.com/support/docview.wss?rs=0&q1=Querydocumentdelete&uid=swg21085485&loc=en_US&cs=utf-8&cc=us&lang=en

My suggestion would be not to give them delete rights in the ACL.

Subject: RE: Re: Prevent Cut to delete documnet in the Embedded view

It appears that an attempt to “Cut” a document will trigger the Querydocumentdelete code, and you can prevent users from cutting a doc the same way you keep them from deleting BUT! it doesn’t work the same in an embedded view - the querydocmentdelete doesn’t get triggered the same.

Anyone else see this problem?

Subject: Post your DB Event code for the Querydocumentdelete

If you provide some more details on what you have tried, it may help us figure out a good solution.

Subject: Re: Post your DB Event code for the Querydocumentdelete

I try with:Dim ws As New NotesUIWorkspace

Dim uiview As NotesUIView

Set uiview = ws.CurrentView

If uiview.viewname = “My_embedded_view_name” Then

continue = False

End If

in the Querydocumentdelete, but I still can delete documents from view by choosing Edit → Cut.

I want to make this embedded view in the form read-only, so that users can only see info in the view, but not delete.