Copy values from the fields between 2 databases

Hello,I have 2 databases. One database has a button that will launch another database. One database is IS ticket, another is SAP auth request. Everything is fine when users are using databases properly. The problem happenes when the user uses IS ticket when trying to create an SAP auth request.

If this happenes, I would like to copy 3 or 4 fields from IS ticket database and create SAP auth request using another database. And copy those 4 fields into the document in that database. I would like yo know if this is possilbe.

If yes, a short example of code would be very halpfull and very appreciated. Thank you very much

Robert Hakala

Subject: copy values from the fields between 2 databases

Robert,

      When you are in database1 --> Use Lotusscript to access the database2. Once you access the database, you can access the view, then the document and pass the document values in to your document in database1. There are lot of example in the designer help. Find the syntax below.

Dim session

Dim database

Dim view

Dim doc2

set database2 = session.getdatabase(“database2”)

set view=database2.getview(“yr view”)

set doc2=view.getdocumentbykey(“yr key”)

dim doc

doc.field=doc2.field2

doc.save

hope it helps.

Raj

Subject: please, check this little code

Thanks for your reply, I did some progress but I’m not done yet. I need something like this:I’m in 1st database and I have a document opened. Than I press a button and some fields will be copied into newly created document in database2. Here’s the code from the button:

Dim session As New NotesSession

Dim ws As New NotesUIWorkspace	

Dim database2 As NotesDatabase

Dim view As NotesView

Dim doc2 As NotesDocument

Dim varName, varAcces As String	

Dim uidoc As NotesUIDocument





Set uidoc = ws.CurrentDocument

varName = uidoc.FieldGetText( "Rpt_User" ) 

varAccess = uidoc.FieldGetText("Rpt_ProblemDetails")



Set database2 = session.getdatabase("VALEOSH_KOS01/S/VALEO", "Kosice\\SAP-auth.NSF")

Set doc2 = database2.CreateDocument

doc2.Form = "CreationSAPBW"

'edit the document, 2 fields are filled out automatically

            doc2.Editdocument(True)   <-- how to this correct?



doc2.Demandeur = varName

doc2.Utilisateur = varName

doc2.Acces=varAcces

'doc2.save

Could you please check this short code? It’s short but still throws me some error - ilegal use of property.

I’ve checked the designer help and I see that I’m using it wrong. it’s just for an illustration of what I’m trying to get… I want to have the document opened for further editing… please help

thank you very much

Robert Hakala

Subject: RE: copy values from the fields between 2 databases

Dim session As New NotesSession Dim ws As New NotesUIWorkspace

Dim database2 As NotesDatabase

Dim view As NotesView

Dim doc2 As NotesDocument

Dim varName, varAcces As String	

Dim uidoc As NotesUIDocument



Set uidoc = ws.CurrentDocument

varName = uidoc.FieldGetText( "Rpt_User" ) 

varAccess = uidoc.FieldGetText( "Rpt_ProblemDetails" )



Set database2 = session.getdatabase("VALEOSH_KOS01/S/VALEO", "Kosice\\SAP-auth.NSF")

Set doc2 = database2.CreateDocument

doc2.Form = "CreationSAPBW"

'doc2.Editdocument(True)



doc2.Demandeur = varName

doc2.Utilisateur = varName

doc2.Acces=varAcces

doc2.Justification = varAcces

Call doc2.save(True, True)

I tried this. The document is created in second database but the passing of the values of the fields is not working… I would like to pass the values and keep the document opened for further editing. Any ideas?

thank you very much

Robert Hakala