I would like to populate a Field on a form in databaseA from a document in databaseB. This is not possible with @GetDocField. How can I accomplish this with LotusScript in the WebQueryOpen event of the form?
The good news is that this is fairly simple! I've included some sample code you can adapt to meet your needs.
On Error Goto Errhandler Dim nsCurrent As New NotesSession Dim ndbCurrent As NotesDatabase, ndbTarget As New NotesDatabase("","") Dim nvwLookup As NotesView Dim ndocTarget As NotesDocument, ndocCurrent As NotesDocument With nsCurrent Set ndocCurrent=.DocumentContext Set ndbCurrent=.CurrentDatabase Set nagtCurrent=.CurrentAgent Set nLogCurrent =.CreateLog( nagtCurrent.Name ) End With Set ndbTarget=nsCurrent.GetDatabase("","target.nsf") Set nvwLookup=ndbTarget.GetView("vwLookupView") Set ndocTarget=nvwLookup.GetDocumentByKey("Key",True) ndocTarget.FieldName=ndocCurrent.FieldName(0) Exit Sub Errhandler: Print "An Error: " & Error & " ( " & Err & ") has occured on line " & Erl & "."
You'll need to change the variables to point to the right places. For example, you need to use a valid key for the GetDocumentByKey call rather than my placeholder "Key" and you need to replace the FieldName with the name of the real source and target fields.