Trash folder

i’m having trouble creating a trash for my application. i did as was in the help file and after reading some posts on the forum;create my trash folder named “($Trash)”.

enabled solf deletions,

even added some coding in the delete query:

'---------------------------------------

Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)

Dim accessgranted As Boolean

Dim flag As Boolean

Set s = New NotesSession

Set db = source.Database

Set acl = db.ACL

Set entry = acl.GetEntry( s.UserName )

Set CollDocDetruit = source.Documents

accessgranted = False

flag = False

'check for the role

Forall r In entry.Roles

If r = “[Admin]” Then

accessgranted = True

End If

End Forall

'check if don’t have the role if it’s

'in draft, you are allowed since you

'only see your documents

If accessgranted = False Then

Set DocDetruit = CollDocDetruit.GetFirstDocument

While Not DocDetruit Is Nothing

If DocDetruitdoc.AlreadySent(0) <> “0” Then

accessgranted = False

End If

Set DocDetruit = CollDocDetruit.GetNextDocument(DocDetruit)

Wend

End If

If accessgranted = False Then

Messagebox “You can only delete drafts”

continue = False

Exit Sub

Else

'user allowed to delete

Set DocDetruit = CollDocDetruit.GetFirstDocument

While Not DocDetruit Is Nothing

'move to trash

DocDetruit.PutInFolder(“($Trash)”)

Set DocDetruit = CollDocDetruit.GetNextDocument(DocDetruit)

Wend

End If

End Sub

'---------------------------------------

and it still doesn’t seem to be working, when i delete it just gets deleted right away.

you have any suggestions on why it wouldn’t work…or maybe i forgot something?

Subject: trash folder

As far as I know 1) Ceate my trash folder named “($Trash)”.

  1. Enable solf deletions.

should do it, you don’t even need the code in QueryDeelete.

When you delete something it usually goes into the Trash folder…guess you checked it. Also check the ODS version of the database.

Subject: trash folder

ok…well i was able to make it work…and after some thourough testing i was able to conclude that the deletion works, but 2 things;1. the deleted docs get removed from the view and it goes to the trash but if i go in the trash folder, i can’t see the documents;if i look at the document counter of the DB properties, they are still there since the counter didn’t move…

2.i had to code the delete in the querydeletedocument


Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)

       'L'usager peut détruire seulement les drafts qui sont à son nom sauf s'il est Administrateur



Dim CollDocDetruit  As NotesDocumentCollection

Dim DocDetruit As notesDocument

Dim UserHasRights As Variant

Dim curStatus As String



Const Macro$ = "@If(@IsMember(""[Admin]"";@UserRoles);-1;0)"



 ' Détermine si l'usager courant détient le rôle 

UserHasRights = Evaluate(Macro$)



 'Si l'usager a le rôle Admin alors il peut détruire des documents

If (UserHasRights(0) = False) Then

	Set CollDocDetruit = Source.Documents

 'Sil y a des documents

	If CollDocDetruit.Count > 0 Then

		Set DocDetruit = CollDocDetruit.GetFirstDocument

      'Tant qu'il a de document a détruire

		Do While Not(DocDetruit  Is Nothing)    

			

           'Si c'est un draft

			If DocDetruit.AlreadySent(0) = "0" Then

				continue = True

			Else

				Messagebox "You can't delete this document"

				continue = False

			End If

			

			Set DocDetruit = CollDocDetruit.GetNextDocument(DocDetruit)

		Loop

	End If

Else

	'admins can delete

	Set CollDocDetruit = Source.Documents

	Set DocDetruit = CollDocDetruit.GetFirstDocument

	Do While Not(DocDetruit  Is Nothing)    

		If DocDetruit.AlreadySent(0) = "0" Then

			continue = True

			Set DocDetruit = CollDocDetruit.GetNextDocument(DocDetruit)

		Else

			'DocDetruit.PutInFolder("($Trash)")				

			'continue = False

			If Not DocDetruit.Remove(True)	 Then

				Messagebox "A document was not deleted because it was being edited somewhere else!"

				Set DocDetruit = CollDocDetruit.GetNextDocument(DocDetruit)

			Else

'gets the deleted doc and moves the one after

'if i just do nextdoc, i get an error.

				Set DocDetruit = CollDocDetruit.GetFirstDocument

				Set DocDetruit = CollDocDetruit.GetNextDocument(DocDetruit)

			End If

		End If

		'Set DocDetruit = CollDocDetruit.GetNextDocument(DocDetruit)

	Loop

End If

End Sub

something that annoys me is that it always prompts to ask me to empty the trash, anyone know how to remove that…

and if i do a ctrl+shit and go to Trash, there are no documents.

any suggestions?