OpenNTF.org - Avoidance of orphan documents
My Links (Not logged in)
Code Bin Search
 
Hosted by Prominic.NET
Rate This Code
5 - brilliant stuff
4 - very nice
3 - average
2 - needs work
1 - bad
   OpenNTF Code Bin
About This Code
Brief Description:
Avoidance of orphan documents in a database 
Rating:
Rating: 3 , Number of votes: 1 
Contributor:
Stefan Brockmann 
Category:
Lotusscript 
Type:
String functions 
Notes Version:
R4.x, R5.x, R6.x 
Last Modified:
14 Jun 2003 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description
If main documents has response documents, but the main document will delete the response documents remain in the database. To delete response documents while deleting the main document use the following code build in the database script section of a database:


Event "Postdocumentdelete"

Verwendung des Script im Abschnitt "Database Scripts" unter "Others":

Usage / Example
Sub Postdocumentdelete(Source As Notesuidatabase)
Dim collCurrent As NotesDocumentCollection
Dim collResp As NotesDocumentCollection
Dim docCurrent As NotesDocument

REM Get the current unprocessed documents for deletion
Set collCurrent = Source.Documents
If collCurrent.Count = 0 Then Exit Sub

REM Set the first document from collection
REM and loop through the collection
Set docCurrent = collCurrent.GetFirstDocument
While Not docCurrent Is Nothing
Set collResp = docCurrent.Responses
If collResp.Count <> 0 Then Call RemoveResponses(collResp)
Set docCurrent = collCurrent.GetNextDocument(docCurrent)
Wend

REM === Recursive routine to delete response and response to response documents ===
Sub RemoveResponses(collCurrent As NotesDocumentCollection)
Dim collResp As NotesDocumentCollection
Dim docCurrent As NotesDocument

REM Set the first document from collection
REM and loop through the collection
Set docCurrent = collCurrent.GetFirstDocument
While Not docCurrent Is Nothing
Set collResp = docCurrent.Responses
If collResp.Count <> 0 Then Call RemoveResponses(collResp)
Set docCurrent = collCurrent.GetNextDocument(docCurrent)
Wend
Call collCurrent.RemoveAll(True)
End Sub
 Comments

No documents found

 Add your comment!