In a previous tip, Mr. Todd Carey, from Missouri demonstrated how to copy a design element from one database to another using some pretty ingenious @Commands.
However there are times when you might need to get a form, a view, a subform or any other design element copied from one database to another.
My solution involves finding out the Unique ID of a design element, getting that document through Lotus Script and copying it to where you need (in this case the user's mail file).
This code can be sent in a button. The only thing you need is to get the Unique ID of the form, view, etc that you want to copy accross. To get the unique ID of a design element, simply ask to see the design element properties. On the first tab, you'll see the Document Unique ID (see first line).
Of course, it's not the UNID that we are going to use. For example, if the design properties says "OFEA870AF2:B03E361A-ON852568EF:00574D42" you need to drop characters 1,2,11,20,21,22,31 so you end up with the a string of 32 characters : "EA870AF2B03E361A852568EF00574D42" that is usable in Notes.
Ok, now that you have the UNID you can email a button to the users that need that new element. The code will be the following, simply update the server name, database name and UNID in the code below and enjoy!
One last word of advice, make sure the source element you are about to copy has its "Do not allow design replace/refresh to modify" checkbox "checked" otherwise there might be cases where you'll loose the element when the Design task runs at night on your server.
Code starts here ...
'==== Declare some variables ==== Dim Session as New NotesSession 'The current session Dim CurrDB as NotesDatabase 'The current mail file Dim SourceDB as NotesDatabase 'The source database of the element dim ElementDoc as NotesDocument Dim CopiedDoc as NotesDocument '==== Initialize some vars ==== Set CurrDB = Session.CurrentDatabase 'Get the current database, it makes for cleaner code Set SourceDB = New NotesDatabase ("SourceServer" , "SourceDB.nsf" ) If SourceDb.IsOpen = False Then Messagebox "An error occured while trying to open up another database. Please contact the person who sent you this button for assistance." , 64, "Error ..." Exit Sub End If '==== Otherwise, get the document === Set ElementDoc = SourceDB.GetDocumentByUNID ( "EA870AF2B03E361A852568EF00574D42" ) If ( ElementDoc Is Nothing ) Then Messagebox "An error occured while trying to get the design element from the source database. Please contact the person who sent you this button for assistance." , 64, "Error ..." Exit Sub End If '==== Well, if we have the source element, why not copy it ? ==== Set CopiedDoc = ElementDoc.CopyToDatabase( CurrDB ) If CopiedDoc Is Nothing Then Messagebox "An error occured while the system was copying the design element into your database. Please contact the person who sent you this button for assistance." , 64, "Error ..." Exit Sub End If Messagebox "A new design element was copied into your database. Please exit your mail file and reopen it so that the system sees that new element. Thanks.", 64, "FYI ..."
This was first published in February 2001