Q
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)
	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.


Dig Deeper on Domino Resources - Part 8

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • 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 ...

SearchDataCenter

SearchContentManagement

Close