Problem solve Get help with specific problems with your technologies, process and projects.

Populate field in databaseA from doc in databaseB

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)
	Exit Sub
	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.

Dig Deeper on Domino Resources - Part 8

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...