Create a Connection Document in the user's NAB


Sub Click(Source As Button)
	
	'First Part
	
	Dim db As NotesDatabase
	Set db = New NotesDatabase( "", "names.nsf" )
	Dim view As notesview
	Set view=db.getview("Connections")
	
	Dim workspace As New NotesUIWorkspace
	Dim uidoc As NotesUIDocument
	Set uidoc = workspace.CurrentDocument
	
	Dim doc  As NotesDocument
	Set doc = view.GetFirstDocument
	Dim docdel As NotesDocument 
	Dim trovato As Integer 
	
	Dim s As New NotesSession
	Dim dbsend As NotesDatabase
	Set dbsend = s.CurrentDatabase
	Dim memo As New NotesDocument(dbsend)
	
	trovato=0
	
	While Not ( doc Is Nothing )
		If doc.Destination(0)="CN=SERVERDOMINO/O=TEST" Then
			Messagebox "The connection document already exist.",  , "Lotus Notes"
			trovato=1
			Set docdel =doc
		End If
		Set doc = view.GetNextDocument( doc )	
		If trovato=1 Then
			trovato=0 
			Goto ESCI
		End If	
	Wend
	
	
	'Second Part
	
	Dim docnew As New notesdocument(db)
	docnew.Form="local"
	docnew.ConnectionType="0"
	docnew.Destination="CN=SERVERDOMINO/O=TEST"
	docnew.OptionalNetworkAddress="192.168.1.100"
	docnew.LanPortName="TCPIP"
	docnew.PortName="TCPIP"
	docnew.Type="Connection"
	docnew.source="*"
	docnew.connectionlocation="*"
	docnew.connectionrecordfirst="1"
	docnew.destinationdomain="*"
	docnew.cost=1
	docnew.enabled="0"
	
	
	Dim success As Variant
	success = docnew.ComputeWithForm( False, False)
	Call docnew.Save( True, True )
	
	
	'Third Part
	
	
	
	Messagebox "Connection document created, Thank you", , "Lotus Notes"
	
	memo.Form = "Memo"
	memo.SendTo = s.UserName
	memo.Subject = "Connection Document created"
	memo.Body = "Connection Document created on " & s.UserName
	Call memo.Send(False,"Admin")
	
	Call uidoc.Close(True)
ESCI:
	
	Call uidoc.Close(True)
	
End Sub
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...