orphand response docs

Hi all,

I have a response hierarchy in one of my databases. Now while testing I have noticed that when I delete the parent document, all other response and response to response documents linked to that deleted parent remain the database. Is there a way that I can make sure that when a main document is deleted its responses and responses to responses are also deleted?

Thank you
Varvoura
varvouraAsked:
Who is Participating?
 
Sjef BosmanConnect With a Mentor Groupware ConsultantCommented:
You might try this:

Sub DeleteDocument( doc As NotesDocument )
     
     Dim dc As NotesDocumentCollection
     Dim respDoc As NotesDocument
     Dim nextDoc As NotesDocument
     
     Set dc = doc.Responses
     If dc.Count=0 Then Exit Sub
     Set respDoc = dc.GetFirstDocument
     Do While Not respDoc Is Nothing
          Set nextDoc = dc.GetNextDocument( respDoc )
          Call DeleteDocument( respDoc )
          Set respDoc = nextdoc
     Loop
     Call doc.Remove( True )

End Sub
0
 
madheeswarConnect With a Mentor Commented:
yes..in the database Script, querydocument delete event, u can delete the child documents of the parent.

See the NotesDocument class for deletion and how to get the childs. (I think get responses)
0
 
varvouraAuthor Commented:
OK, here's a script

Sub DeleteDocument( doc As NotesDocument )
      
      Dim dc As NotesDocumentCollection
      Dim respDoc As NotesDocument
      Dim nextDoc As NotesDocument
      
      Set dc = doc.Responses
      Set respDoc = dc.GetFirstDocument
      
      While Not respDoc Is Nothing
            Set nextDoc = dc.GetNextDocument( respDoc )
            Call DeleteDocument( respDoc )
            Set respDoc = nextdoc
      Wend
Call doc.Remove( True )

end sub

I place the above as a function in the database script section.
Then in the querydocumentdelete of the database script I call the function, but nothing happens.
Is my call to the function incorrect or should this not be in the querydocumentdelete section?



Call deletedocument(doc)
      
            
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
varvouraAuthor Commented:
Even when I paste this in view event and call it from the view which has the parent document, i still have no luck.
0
 
Sjef BosmanGroupware ConsultantCommented:
http:Q_20569942.html "recursivelly marking responses for deletion"

And look at the PostDocumentDelete event in the Database script (under Other/Database Resources)
0
 
varvouraAuthor Commented:
I'll give this a try.
However, just curious to why my function above did not work. Is the call to the function incorrect?

0
 
varvouraAuthor Commented:
Still a problem, but maybe it is the way i am applying this.
If I have problems I move to your recommeded link.

Thank heaps for trying to help, I really appreciate it.


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.