Link to home
Start Free TrialLog in
Avatar of Enrique040897
Enrique040897

asked on

Passing arguments when creating a new document

From a document opened, I want a buttom to create a new document in another database on the same server, but I want to have a link to the new document, in order to associate the two documents.  I do prefer to create the new document and have the possibility to edit that new form.  I did try with @Command([compose];), but I do not know how to pass the link. Please assist.
Avatar of Arunkumar
Arunkumar

Well, unless you dont save the current document you cannot pass the document link to the other database...
Hi there !

Try this code. This will save the current Document and create a link in the target database.  You cannot do a link without saving the current document.  Thats why this approach.

Change all the values and just put it under a button.

Good Luck!
Arun.
     
     
     Dim ss As New notessession
     Dim ws As New NotesUIWorkspace    
     Dim uidoc As NotesUIDocument    
     Dim db As NotesDatabase
     Dim tardb As NotesDatabase
     Dim curDoc As NotesDocument
     Dim tarDoc As NotesDocument
     Dim rtitem As NotesRichTextItem
     
     Set db = ss.CurrentDatabase
     Set tardb = New NotesDatabase( ss.CurrentDatabase.Server , "data\am174\webtest.nsf") ' Change the path for new database
     
     Set curDoc = db.CreateDocument
     curDoc.Form = "Test"  'The name of the form that you are composing....
     Call curDoc.Save(True,False)
     
     Set tarDoc = tardb.CreateDocument
     tarDoc.Form = "Test1" ' The form name in the target database
     Set rtitem = New NotesRichTextItem(tardoc , "Body" ) ' Body is the Field that contains the doc link
     Call rtitem.AppendDocLink(curDoc , "Alternate text when moused !" )
     
     Call tarDoc.Save(True , False)
     
     Set uidoc = ws.EditDocument(True , curDoc , False , "" )    
What i am doing in the code is...

Create a document "A" and save it.
Create a document "B" with doclink in the second database pointing to document "A".
Now open document "A" in edit mode as if you are composing the document.

If you wish to cancel the opened document its not possible now since there is already a document pointing to this one and this one is already saved.

:-(
Avatar of Enrique040897

ASKER

Sorry for the delay. I was not on my workplace. I will let you know. But I want something like this.  Just imagine that you are filling a person record.  Then, you want to add dependant records.  Those records should be linked to the person record.  Then, if I want to open a person record, I can be able to access its dependant records.
ASKER CERTIFIED SOLUTION
Avatar of Arunkumar
Arunkumar

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Arunkumar , could you please modify the script in order to use it from an opened document. (to create a new document from an opened document.