Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

agent to read a view and use the unique id to find inherit document 1

Status
Not open for further replies.

Julie845

Programmer
Oct 9, 2003
11
US
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
 
Try something like this. I haven't tested it but I think it should work.

Code:
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top