Solved

connection document

Posted on 2010-11-10
11
1,005 Views
Last Modified: 2013-12-18
I have create a button in Lotus script for automatic edit/creation of lotus notes connection document. Problem, when users press the button script regularly create/edit connection document but users don't have ability to connect to server until they go to connection, open edited/created connection document and answer yes for message they get (see pic in attachment).
Any ideas how to avoid this problem?
connection.jpg
0
Comment
Question by:Styria-it_hr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
11 Comments
 
LVL 22

Expert Comment

by:mbonaci
ID: 34103380
I think the fact that they cannot use the connection doc is not due to this message (unless tcp port is disabled (not checked) in connection documents your code creates/edits).
That message only changes port field and saves the document.

Try adding document.ComputeWithForm at the bottom of your code, just before saving the document.
0
 
LVL 22

Accepted Solution

by:
Bill-Hanson earned 250 total points
ID: 34103750
I would add code to check the user's available ports, then set the field explicitly.

@GetPortsList([ENABLED]) can be used to get the list of enabled ports.

The name of the field on the Location doc is "EnabledPorts".  So you could write...

FIELD EnabledPorts := @GetPortsList([ENABLED]);

I don't think @GetPortsList has a LotusScript equivalent, but you can always use Evaluate.
0
 

Author Comment

by:Styria-it_hr
ID: 34109957
mbonaci;
I tried to put document.ComputeWithForm but I'm always getting variant does not contain an object error.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 34110802
Styria-it_hr:  Please post your code.
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 34111622
"document" has to be actual NotesDocument (connection document), maybe you named the variable doc, or something similar.
0
 

Author Comment

by:Styria-it_hr
ID: 34112353
Sub Click(Source As Button)
      
                     Dim session As New NotesSession
      Dim workspace As New NotesUIWorkspace
      Dim db As New NotesDatabase( "" , "Names.nsf" )
      Dim doc As NotesDocument
      Dim success As Variant
      Dim view As NotesView
      
      Set view = db.GetView( "Connections" )
      Set doc = view.GetDocumentByKey("serverXXXY")
      
      If doc Is Nothing Then
            Set doc = New notesdocument(db)
            doc.Form="Location"
      End If
      
      doc.Form = "local"
      doc.Destination = "ServerYYYY"
      doc.PortName = "TCPIP"
      doc.Type = "Connection"
      
      doc.ConnectionLocation="*"
      doc.ConnectionType="0"
      doc.DestinationDomain="*"
      doc.DocumentAccess="[NetModifier]"
      doc.Enabled="0"
      doc.LanPortName="TCPIP"
      doc.OptionalNetworkAddress="ServerXXYY"
      doc.Source="*"
      
      success = doc.ComputeWithForm( False, False )
      If success Then
            Call doc.Save( True, True )
            Call workspace.AddDatabase( "" , "Names.nsf" )
            Msgbox "message1", 64, "message2"
      End If
End Sub
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 34112446
What this line means:
    doc.Form = "local"

There's no such form in private address books, so ComputeWithForm is using default db form (Contact/Person) to evaluate the fields.

Should be:
    doc.Form="Location"

You can still save a document if the ComputeWithForm returns False or raises an error.
I mean, it's better for an user to open and save the doc, then not having the connection doc at all. So don't condition the save method with success.
0
 
LVL 22

Assisted Solution

by:mbonaci
mbonaci earned 250 total points
ID: 34112519
Ups, that should've said:
    doc.Form = "Connection"
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 34112610
Bill,
I'm not sure whether @GetPortsList returns list of enabled ports from Notes.ini or from current location doc, since Designer help says:
    "@GetPortsList is used by the Public and Personal Address books to determine the list of available ports for each Location record."

If it gets the info from location doc it wouldn't be of any use here, right?
Although it wouldn't be the first time the help is not correct.
0
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 34115259
Actually, it reads directly from notes.ini.

@GetPortsList( [ Enabled] ) reads the 'Ports' variable and...

@GetPortsList( [ Disabled] ) reads the 'DisabledPorts' variable.

The key phrase in the help document is 'used BY the Public and Personal Address books'.  The address books use this function in their design to know the picklist choices for the 'EnabledPorts' field.  Open the 'Location' form in the designer, and you'll see what I mean.
0
 
LVL 22

Expert Comment

by:Bill-Hanson
ID: 34115615
Well, if it were me, I'd write it like this.  My goal is to never write the same code twice, so whenever I do this much work on a function, I make sure and parameterize it so I can paste it into a library.  This function takes a server name and an address then returns true if the connection was created, or false if it already existed.

The big change here is where we read the enabled ports directly from notes.ini.  Try it out.  I can't guarantee that your users will connect right away without knowing your environment, but at least the Connection Doc will be correct, and they won't get that annoying message.
Public Function createConnection(server As String, address As String) As Boolean
	
	Dim session As New NotesSession
	Dim workspace As New NotesUIWorkspace
	Dim db As New NotesDatabase( "" , "Names.nsf" ) 
	Dim doc As NotesDocument
	Dim success As Variant
	Dim view As NotesView
	
	' check for existing connection
	Set view = db.GetView( "Connections" )
	Set doc = view.GetDocumentByKey(server)
	If (Not doc Is Nothing) Then Exit Function
	
	' create connection
	Dim ports As Variant
	ports = Split(session.Getenvironmentstring("Ports", True), ",")
	Set doc = New NotesDocument(db)
	doc.Form = "local"
	doc.Destination = server
	doc.PortName = ports
	doc.Type = "Connection" 
	doc.ConnectionLocation="*"
	doc.ConnectionType="0"
	doc.DestinationDomain="*"
	doc.DocumentAccess="[NetModifier]"
	doc.Enabled="0"
	doc.LanPortName = ports
	doc.OptionalNetworkAddress = address
	doc.Source="*"
	
	' save new connection
	Call doc.ComputeWithForm( True, False )
	Call doc.Save( True, False )
	Call workspace.AddDatabase( "" , "Names.nsf" ) ' not sure why this line needs to be here
	createConnection = True
	
End Function

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question