I’m trying to use LotusScript to find all records in a view that have a field value that matches the open document.
Once those documents have been found I want to perform several actions on all matching documents (make responses to a new order document) then set a field to indicate that they have been updated.
I’ve tried all sorts of things, including view.GetDocumentByKey(CustOrderNo) and dc.GetFirstDocument but seem to be having difficulties getting a match beyond the first record.
I’ve created a view “vMigrate” which has it’s first column sorted and categorized on the field containing the field to be matched “order_no”.
Err, yes… I’m a novice, but having a go!
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim NewOrder As NotesDocument
Dim openDoc As NotesDocument
Dim workspace As New NotesUIWorkspace
Dim Cworkspace As New NotesUIWorkspace
Dim CurrentopenDoc As NotesUIDocument
'get the open doc selected and available for copy into new order
Set currentopenDoc = Cworkspace.CurrentDocument
Set openDoc = Currentopendoc.Document
'creates New Order using form “fOrder”
Set NewOrderDoc = workspace.ComposeDocument(“”,“”,“fOrder”)
Set NewOrder = NewOrderDoc.document
'populate fields in newOrder using entries in open document e.g.
Call NewOrderDoc.fieldsettext(“CustomerOrderNumber”,CurrentopenDoc.FieldGetText(“Order_No”))
'etc
’ Save the newOrder
Call NewOrderDoc.Save()
'List orders that match open doc’s “Order_No” field (text)
'Dim dc As NotesDocumentCollection
Dim CustOrderNo As String
CustOrderNo = CurrentopenDoc.FieldGetText( “Order_No” )
Messagebox(“check order no of open document” + CustOrderNo)
'use the openDoc Order_No as the key
Dim view As NotesView
Set view = db.GetView( “vMigrate” )
Dim doc As NotesDocument
Set doc = view.GetDocumentbykey (CustOrderNo)
While Not ( doc Is Nothing )
'next if statement doesn’t work
'If doc.fieldGetText(“migrated”) <>“y” Then
Call doc.MakeResponse(NewOrder)
doc.migrated = “y”
'change form to response form
doc.form = “fResponseform”
Call doc.Save( True, False )
Set doc = view.GetNextDocument( doc )
'End If 'removed as doesn’t work
Wend
End Sub
Suggestions very welcome… many thanks!