IBM Support

Creating Connection documents using LotusScript

Technote (FAQ)


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?


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. If you wish to update existing Connection documents, refer to "How to programmatically update or remove Connection documents from a Personal Name and Address Book" (#1208108).
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.close
End Sub

Related information

Update or remove Connection documents from a NAB

Document information

More support for: IBM Domino Designer

Software version: 6.0, 6.5, 7.0, 8.0, 8.5, 9.0

Operating system(s): Windows

Reference #: 1110951

Modified date: 29 October 2015

Translate this page: