agent to read a view and use the unique id to find inherit document
agent to read a view and use the unique id to find inherit document
(OP)
I would like update my "inherit values" on a form with an agent. I have already one view with the records(parents) updated by my user with a specific flag to trace them. I have a view where my children are listed. Now, I have to generate the agent to read the first view, access the second one, find the correct records and update them
but here.... I'm blocked. I'm not able to write properly my lotusScript to do it.... Please help, what I'm doing wrong ?
thanks
Julie
but here.... I'm blocked. I'm not able to write properly my lotusScript to do it.... Please help, what I'm doing wrong ?
thanks
Julie
RE: agent to read a view and use the unique id to find inherit document
ΓΏ
Sub Initialize
'Visit all main documents to get values
'Verify values on response document to main and update if they are different
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim parentDoc As NotesDocument
Dim responseDoc As NotesDocument
Set db = session.CurrentDatabase
Set view = db.GetView( "View Name" )
Set parentDoc = view.GetFirstDocument
'START: Visit each main document in the view
While Not ( parentDoc Is Nothing )
'START - Get values of main doc
v1=parentdoc.field1(0)
v2=parentdoc.field2(0)
v3=parentdoc.field3(0)
' and so on with all fields you wish to update
'END - Get values of main doc
'START: Visit each of the parent's response documents
Set responseDoc = view.GetChild( parentDoc )
While Not (ResponseDoc Is Nothing )
'START - Get values of resp doc
If v1<>ResponseDoc.field10) Then
ResponseDoc.field1=v1
End If
If v2<>ResponseDoc.field2(0) Then
ResponseDoc.field2=v2
End If
If v3<>ResponseDoc.field3(0) Then
ResponseDoc.field3=v3
End If
' and so on for all your response do fields
'END - Get values of resp doc
Call ResponseDoc.ComputeWithForm( False, False )
Call ResponseDoc.Save( True, True )
Set responseDoc = view.GetNextSibling( responseDoc )
Wend
Set parentDoc = view.GetNextSibling( parentDoc )
Wend
'END: Visit each main document in the view
End Sub
[\Code]
Hope this helps