Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy document from one database to another one, using pickist

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello,

By clicking on a button (@picklist), I can see the document from another DB (on the same server).
Is there a way to copy the selected document from this db, to the current db (where my button is)? Using function or lotusscript.
Thx

PS : I'm using v5
 
Hey the_egyptian:

I'm not certain if the syntax would carry over from R4 to R5. However, I'm pretty sure the following logic would be consistent.

If you can get a handle to a document using the @Picklist function, then you should be able to set an environment variable to grab the sought-after document's Universal document ID, and then use Lotusscript to copy that document from "thisdb" (an external database) to the current db where your button is located. Below is a general workflow and code sample:

Sample Button Code:
server:="\Dev";
file:="\testing.nsf";
view:="Target Document View";
prompt:="Let's copy this document from the testing database on the Dev server to the current database."
column:=1;
getid:=@picklist( [Custom] : [Single] ; server : file ; view ; title ; prompt ; column )
docid:=@Text(getid); 'just to make sure it's text formatted
REM "I would recommend that you make the universal ID
(@Text(@DocumentUniqueID)- the value recalled in the first column of the view in which your button is located. Bear in mind that this column must be sorted in ascending order in order for the value returned by the picklist to be eligible for use as a key by the script to follow. It must also be of a data type string (text).";
REM "Then, set an environment variable in the @Command language equal to the value of the Universal ID of the document returned by your Picklist. It is recommend that you use @Prompt([OK]) to validate the document you have selected before you move on to the copy routine.";
@Environment("key";docid);
REM "The following line references a shared LotusScript agent named Copydoc which will be used to copy the selected document to the desired location...";
@Command([ToolsRunMacro];"CopyDoc");
"This agent should contain the following code. Refer to Programmers Guide Part 1 Chapter 3: Page 89, Section 2... copying a document in LotusScript... I have catered the code to your question here.";


Sub Initialize ' Copydoc agent
Dim session as New NotesSession
Dim currentdb as NotesDatabase ' database you are in
Dim thisdb as NotesDatabase ' database you are searching
Dim returndocid As String
Dim doc as NotesDocument
Set currentdb=Session.currentdatabase
Set thisdb="\Dev\testing.nsf"
returndocid=session.getenvironmentstring("key")
Dim view as NotesView
' set the view from which you are getting the doc to copy
Set view=thisdb.getview("Target Document View")
' set the doc value based on the lookup by enviro variable
Set doc=getdocumentbykey(returndocid,True)'must be exact txt
Call doc.CopytoDatabase(currentdb)

End Sub

---------- End Code ---------


That should help you copy a document from one db to another, ot get you pretty close. Let me know if you have any difficulty implementing any of this code, or have any questions on the logic employed. There is definitely more than one way to solve the question you had posed. This is my recommendation...

Good luck,
Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top