Creating Connection documents using LotusScript
Herzlich Willkommen!/Tipps & Tricks/Creating Connection documents using LotusScript

Creating Connection documents using LotusScript

You want to mail a hotspot button to users that will create or update a Connection document in their local address books. How can this be done using LotusScript?
 
From the Lotus Support Services Technote #1110951:

Problem


You want to mail a hotspot button to users that will create or update a Connection document in their local address books. How can this be done using LotusScript?
 

Solution


You can use one of the LotusScript coding methods below to create or update Connection documents in a user’s local address book. The first method is useful when creating a Connection document that has no restrictions on who or how it is used. The second method demonstrates an example that allows you to set particular field values.
 

Using LotusScript with automatic generation feature

One of the highlights introduced with the R5 client is automatic generation of Connection documents when you enter the host name (or IP address) of a Domino server in the Open Database dialog box. Notes creates the Connection document with the server’s fully hierarchical name in the "Server name:" field and the host name in the "Destination server address:" field. The "For user" and "Applies to Location(s)" fields are populated with an asterisk (*).
So, while LotusScript could easily create and populate a Connection document in a user’s Personal Name and Address Book, you can make use of the functionality noted above to create a Connection document without extensive coding. In the below examples, "x.x.x.x" represents the host name or IP address. This value is placed within quotes in the LotusScript.
If you want to open a particular database while also creating the Connection document, then the OpenDatabase method (of the NotesUIWorkspace class) could be used as follows:
Dim ws As New NotesUIWorkspace Call ws.OpenDatabase("x.x.x.x","dbname.nsf")
If you want to add the Connection document but only add the database’s icon to the workspace, then the AddDatabase method (of the NotesUIWorkspace) class could be used as follows:
Dim ws As New NotesUIWorkspace Call ws.adddatabase("x.x.x.x","dbname.nsf")
If you simply want to add the Connection document, then the New method (of the NotesDatabase class) code could be used:
Dim db As New NotesDatabase("x.x.x.x", "names")
If you intend to mail the code to users in a button, then place the code in the Click event.
 

Using LotusScript to set particular fields in a Connection document

The following example is similar to the example above and uses the logic you had to use to accomplish this task in Notes releases prior to 5.0. You can use this method if you want to set additional field values in the Connection document. For example, if you want to set the connection so that it is available only when certain Location documents are used, you would set the value for the ConnectionLocationfield. As above, you can send this code in the Click event of a hotspot button within an email to all users who need the updated or new Connection document.
Sub Click(Source As Button) Dim Workspace As New NotesUIWorkspace Dim UIDdoc As NotesUIDocument Set uidoc = workspace.composedocument("","names.nsf","Connection") Call uidoc.fieldsettext("ConnectionType","Local Area Network") Call uidoc.refreshhideformulas Call uidoc.fieldsettext("PortName","TCPIP") Call uidoc.fieldsettext("LanPortName","TCPIP") ' The FieldSetText method could be used here to set the values of other fields ' For example, the below allows the connection to only be used when ' either the OfficeA or OfficeB location documents are in use. Call uidoc.fieldsettext("ConnectionLocation","OfficeA, OfficeB") Call uidoc.refreshhideformulas Call uidoc.fieldsettext("Destination","Server/Organization") Call uidoc.fieldsettext("OptionalNetworkAddress","x.x.x.x") Call uidoc.fieldsettext("Source","*") Call uidoc.refresh Call uidoc.save Call uidoc.close End Sub