Hello to everybody. I have 2 databases. In database A i have a code that through a window I select a document of the database B. I need that, upon selecting, beyond fill a field with the referencia, put a link of the document of the database B in a RichText field of the database A. Can anyone help me?
Subject: Put a document link from anither database
Hello,
Here is the script that I used for putting the Doclinkss using Picklistcollection . U can modify the script as per ur requirements:
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim uidoc As notesuidocument
Dim currdoc As notesdocument
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim rtf1 As notesrichtextitem
Dim item,item1 As NotesItem
Dim dbname,dbserver As String
Set db = session.CurrentDatabase
Set currdoc = workspace.CurrentDocument.Document
dbname = “DatabaseName” 'U can keep this parameter in a profile doc
dbserver = “ServerName” 'U can keep this parameter in a profile doc
Set collection = workspace.PickListCollection( _
PICKLIST_CUSTOM, _
True, _
Cstr(dbserver), _
Cstr(dbname), _
“View Name in Other Database”, _
“Linked Documents”, _
“Please select a document.” )
If collection.Count = 0 Then
Messagebox "User canceled" ,, _
"No Documents selected to be linked."
Else
Set doc = collection.GetFirstDocument
Set rtf1 = currdoc.GetFirstItem(“rtfODL”)
If rtf1.type = RICHTEXT Then
While Not ( doc Is Nothing )
If ( rtf1 Is Nothing ) Then
Exit Sub
Else
Call rtf1.AddNewline(1)
Call rtf1.AppendText(“Document : " & doc.comprefNo(0) &” is linked . Please click on the doclink to open the document")
Call rtf1.AppendDocLink(doc,“test”)
End If
End If
Set doc = collection.GetNextDocument (doc)
Wend
End If
End If
Call currdoc.save(True,True)
currdoc.saveoptions = “0”
Set uidoc = workspace.currentdocument
Call uidoc.Close
Call workspace.editdocument(True,currdoc)
Msgbox “Please save the document using the Save button before linking other documents.”,0,“Save Document”
Its important that u save, close and open the document again, as to show the content on RTF fields they require the document to be saved and reopened.
HTH
Tom
Subject: Put a document link from another database
Tanks Thomas,
But in instruction:
Set rtf1 = currdoc.GetFirstItem(“rtfODL”)
return an error because is a new document and the richtext rtfDOC is empty. Can you help me with this?
Tanks
João Barbosa
Subject: Put a document link from anither database
Not sure what this means"upon selecting, beyond fill a field with the referencia"
Anyway, I have done this (all in one database to be fair, but the principle is the same) using EditMakeDocLink command:
FIELD ChangeReqNo:=ChangeReqNo;
@Command([OpenView];“(CRSBYNUM)”;ChangeReqNo);
@Command([OpenDocument];“1”);
@Command([EditMakeDocLink]);
@Command([CloseWindow]);
@Command([CloseWindow]);
@Command([EditGotoField];“ABDocLink”);
@Command([EditPaste]);
@All
Maybe you could use that with the addtion of OpenDatabase command:
FIELD ChangeReqNo:=ChangeReqNo;
@Command([FileOpenDatabase];“Development”:“PROBLEMS.NSF”);
@Command([OpenView];“(CRSBYNUM)”;ChangeReqNo);
@Command([OpenDocument];“1”);
@Command([EditMakeDocLink]);
@Command([CloseWindow]);
@Command([CloseWindow]);
@Command([EditGotoField];“ABDocLink”);
@Command([EditPaste]);
@All
Everyone is not liking my field declarations on here, so maybe you can remove FIELD Fieldname:=Fieldname.
(I still have code on 6.5.3 that only works when the fields are declared)