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.
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 ?
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)