Parent & Child Document Association Problem

I have a database that defaults on opening to a view that displays “all” documents - parent docs with the child docs under them (hierarchy). For some reason today, I have several hundred child documents located at the bottom of the view under a (Not Categorized) twistie. Also these child documents are not updating their parent document when saving as in the past. It appears for these stray documents the connection between the parent and these child documents do not exists.

I just created a new parent and child document and they work fine so my guess is there is no problems with either of the two forms.

Any suggestions ?

Subject: Who likes response documents, anyway?

I gave up on response documents years ago. The problem you describe is typical. God forgive you should lose the handle to the parent …

I assign my own relational variables like

threadUNID

parentUNID

I have to use a couple more lines of code here and there, but I don’t even think about problems like the one you’re faced with.

Subject: RE: Who likes response documents, anyway?

The parent documents have not been deleted. When I do a search on a field that is common to both the parent and the child in an “all documents” view they are both retrieved. The problem is the child has lost it’s $Ref & ParendID info causing the link to be broken between the parent and chid. Any way to reconnect these documents ?

Subject: RE: Who likes response documents, anyway?

I agree, response docs can be difficult when connections are lost. But they are necessary in most Notes applications I have ever developed.

Anyway, you can set $Ref just like any other field. Use @SetDocField($Ref; DocUNIDvariable) or in script, either childdoc.MakeResponse(parentDoc), or set the field directly childdoc.~$Ref = parentUNIDvariable (use tilde in front of $ fields to set them via the back end calls).

Subject: RE: Who likes response documents, anyway?

Thanks to you all or your help. I have determined that on the documents that are not a problem, (the $Ref is not blank), the ParentID fields and the $Ref fields are identical. If I can copy the data from the ParentId field to the $Ref field the issue should be corrected. I tried both versions below using the standard @Setfield code below but it’s not working. Any ideas ?

@SetField(@Text($Ref);@Text(ParentID));

SELECT @All

@SetField($Ref;ParentID);

SELECT @All

Subject: RE: Who likes response documents, anyway?

@SetField(“$Ref”;ParentID);

Subject: Parent & Child Document Association Problem

More Info On problem - The $Ref field for all these stray documents are showing “F00000000:00000000-N00000000:00000000”.

Subject: Parent & Child Document Association Problem

Bobby,

Some possibilities:

  1. Parent docs were deleted, child docs were not

  2. Maybe some workflow or querysave code that changes the parent that a child doc has … and this code is inaccurate

  3. Maybe these have been around for a long time, slowly accummulating. The only relevance here is that you may be looking for a new or old problem.

good luck,

raphael

Subject: RE: Parent & Child Document Association Problem

Is there not a way to display a $Ref or ParentID field in a view? I need to do that to help determine the scope of this problem and it’s solution.

Subject: RE: Parent & Child Document Association Problem

Use @text() around any document UNID to see it in a view, in this case use @Text($Ref)

Subject: RE: Parent & Child Document Association Problem

To prevent this in the future… add this code to your ‘Database Resources’ section… then when a document is deleted, any ‘children’ associated with it will be deleted too… no more orphans (consider using Allow Soft Deletions and creating a view that shows deleted docs so you can track this if desired)

Sub PostDocumentDelete(Source As NotesUIDatabase)

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim coll As NotesDocumentCollection

Dim coll2 As NotesDocumentCollection

Dim curdoc As NotesDocument

Set db = source.Database

Set coll2 = source.Documents

Dim x as Integer

For x = 1 To coll2.Count

Set curdoc = coll2.GetNthDocument(x)

Set coll = curdoc.Responses

If coll.count > 0 Then Call coll.RemoveAll(True)

Next

End Sub