Re-associate one doc to another

This code was used to manually re-associate two records. The user just selects the two records and the agent code automatically determines which one is the parent and which one is the child. Then it performs the re-association and saves.

Dim session As New notessession
Dim db As notesdatabase
Set db = session.currentdatabase
Dim collect As notesdocumentcollection
Set collect = db.unprocesseddocuments
If collect.count = 0 Then Exit Sub

If collect.count <> 2 Then
	Msgbox "you must select 2 records only."
End If
Dim doc As notesdocument
Dim pdoc As notesdocument
Dim cdoc As notesdocument
Set doc = collect.getfirstdocument
	If doc.form(0) = "UP" Then
		Set pdoc = doc
	Elseif doc.form(0) = "DBAP" Then
		Set cdoc = doc
	End If
	Set doc = collect.getnextdocument(doc)
Loop Until doc Is Nothing
If pdoc Is Nothing Then Exit Sub
If cdoc Is Nothing Then Exit Sub
If pdoc.up_uniqueID(0) = cdoc.up_uniqueID(0) Then
	Call cdoc.MakeResponse( pdoc )
	Print "Successfully matched. " + Now
End If

Posted by fbrefere001 on Thursday February 23, 2006