Copying form field data from one database to another

25 pts.
Domino Designer
Domino Designer 6.5
How would I copy the contents of numerous fields in one form to a form in another database? I am not very good at using LotusScript and prefer to use the Formulas.

Answer Wiki

Thanks. We'll let you know when a new response is added.

From Ruth:
You can use the @MailSend function, and mail the data from your fields to ar form in the other database, just make sure the target database is a mail in database, then you can manipulate it from there using agents.
Ruth Inman


There are so many ways to do this that it is almost impossible to answer. Can you give more details on the requirements? Do you have the ability to go to some more advanced training?

Discuss This Question: 8  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Ledlincoln
    Your question is not clear. Are you copying a form or a document or numerous documents? Are you copying data or design elements? Is this a one-time thing, or a recurring need? In many cases, the Windows copy and paste features work great for Notes, but again, it depends on what you are trying to accomplish.
    1,620 pointsBadges:
  • Mrainer
    If you want to copy a document from one database to another, the only way that I have found to do this is formula is to mail it to the new database. It's not hard to do in script. But maybe you are trying to copy just a few fields from a document in one database to the form in another.
    115 pointsBadges:
  • GreendBend
    I realize now that I was not providing details on what I am proposing to do using the formulas. So, here are the details: 1. From database one, open the form 2. Fill in the details on the form (approximately 20 fields). 3. Save the form. 4. From within the database one form, click on a button to open database two. 5. Open the database two form. 3. Copy contents of the 20 fields from database one to database two. 4. Save and close both forms. Note: neither database is using mail in our mail out functions. If someone has an easy way to do this via formulas, or even better a step by step process for LotusScript, I would forever be in your debt. Hopelessly lost...
    25 pointsBadges:
  • SlikTool
    There is a way to do this both in LotusScript and Formula. If you use Formula you must do the work from within the 2nd database though. I should mention that one detail missing from your explanation is whether this is suppose to be an automatic process or user triggered. This explanation assumes that a user is involved. If it is suppose to be automatic then a change is necessary. These examples assume that a user working in the 2nd database will open a document based on form2 and the contents will be populated by the values on a document created by form1 in the 1st database. @Formula: In the Form on the second database use the @DBLookup formula to compute each field on the (or the default value) form. This is somewhat inefficient though. Nonetheless, it will work. This means the documents created by the form in the 1st database need to be in a view and retrievable by a key. Hence a possible "issue", how does the 2nd database know the key? You could do some work with @DBColumn for this - but it gets a little "kluggy" without user interaction. I would suggest having 1 field on the new form in the 2nd database be a dialog list/combo box that derives its values from the @DBColumn of the first column in the 1st database. When the user chooses a value from the list, then the rest of the fields populate using @DBLookup and this value as the key. This means the key on the document in the 1st database needs to be unique for each document. Make sense? Lotus Script: Using LScript for this solution is easier from a coding standpoint - however picking the when and where is more of a challenge. As an example, you could use the same scenario as above where a dialog list/combo box field uses a @DBColumn to get the keys of documents available in the 1st database, then on the change of the value of that field, a form refresh occurs and the following code get put in the QueryRecalc event - of course this code will run every time the QueryRecalc event is triggered so it may not be the best place to do it. Dim session as New NotesSession Dim seconddb as NotesDatabase Dim secondview as NotesView Dim seconddoc as NotesDocument Dim keyVal as string 'server name and file paths are string, enter them between double quotes Set seconddb = New NotesDatabase( serverName$, filePath$) 'view name is a string enter it between double quotes, if there is an alias, use it instead of the name 'remember the first column in that view must be sorted one way or the other for this to work Set secondview = seconddb.getview( viewName$ ) 'source is the current UI doc and is already set by the QueryRecalc event - no DIM required 'comboboxfield$ is a string, enter name of field between double quotes keyVal = source.fieldgettext(comboboxField$) Set seconddoc = secondview.getdocumentbykey( keyVal, true ) forall i in seconddoc.items call source.fieldsettext(, i.values(0) ) end forall This was not tested, but should work or be close enough to finish it up.
    1,870 pointsBadges:
  • Ledlincoln
    If it's your intention to create a new document in Database Two each time, take a look at the CopyToDatabase method. Set newNotesDocument = notesDocument.CopyToDatabase(notesDatabase) The code would be something like this: Dim workspace as New NotesUIWorkspace Dim uidoc as NotesUIDocument Set uidoc = workspace.CurrentDocument Dim db2 as NotesDatabase Set db2 = New NotesDatabase("ServerName", "FileName") Dim thisdoc as NotesDocument Set thisdoc = uidoc.Document Dim newdoc as NotesDocument Set newdoc = thisdoc.CopyToDatabase(db2)
    1,620 pointsBadges:
  • GreendBend
    Thank you everyone for all of your suggestions. Ledlincoln, as for creating a new document each time in database two, yes that is my intention. However, I only want to copy the data from a select number of fields in the form on database one to the database two. I have been successful in opening database two from database one and creating the designated form in database one. My issue still lies with copying the data from the specific fields, as I don't want everything copied.
    25 pointsBadges:
  • Ledlincoln
    Okay, I have copied specific lists of fields in many situations. Here's one example, essentially verbatim:
    Sub copyReq
    	Dim fieldlist(15) As String
    	fieldlist(0) = "SuggVendor"
    	fieldlist(1) = "SuggVendorName"
    	fieldlist(2) = "SuggVendorPhone"
    	fieldlist(3) = "DeliverTo"
    	fieldlist(4) = "LineItemCount"
    	fieldlist(5) = "Quantities"
    	fieldlist(6) = "Units"
    	fieldlist(7) = "VendorPartNos"
    	fieldlist(8) = "PartNos"
    	fieldlist(9) = "UnitPrices"
    	fieldlist(10) = "ExtPrices"
    	fieldlist(11) = "Descriptions"
    	fieldlist(12) = "Comments"
    	fieldlist(13) = "Readers"
    	fieldlist(14) = "ReqDescription"
    	fieldlist(15) = "Prototypes"
    	Set collection = db.UnprocessedDocuments
    	Let cc% = collection.Count
    	If cc% <> 1 Then
    		Msgbox "You must select only one req to copy", , "Select One Req"
    		Exit Sub
    	End If
    	Set thisdoc = collection.GetFirstDocument
    	Dim newdoc As New NotesDocument(db)
    	Call newdoc.ReplaceItemValue("Form", "New Req")
    	Call newdoc.ReplaceItemValue("Status", "New - Not Submitted")
    	Call newdoc.ReplaceItemValue("Authors", Session.CommonUserName)
    	For f% = 0 To Ubound(fieldlist)
    		Set item = thisdoc.GetFirstItem(fieldlist(f%))
    		If Not (item Is Nothing) Then
    			Call newdoc.CopyItem(item, "")
    		End If
    	Next f%
    	Call workspace.EditDocument(True, newdoc)
    End Sub
    1,620 pointsBadges:
  • Ledlincoln
    Erratum: The forum "helpfully" converted "session.Co_mmonUserName" to a weblink in the line with the Authors field. Call newdoc.ReplaceItemValue("Authors", session.Com" title="http://Session. " target="_blank">Session.Com</a>monUserName)
    1,620 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: