2

In a LotusScript Agent that is being run via WebQueryOpen, how do you get the name of the current server?

Tim Frey
  • 9,901
  • 9
  • 44
  • 60
Derek
  • 16,181
  • 3
  • 27
  • 36

4 Answers4

5
Set s = New NotesSession
Set db = s.CurrentDatabase

If db.Server <> "" Then
  Set sName = New NotesName(db.Server)
Else
  Set sName = New NotesName(s.Username)
End If
Benjamin Autin
  • 4,143
  • 26
  • 34
Derek
  • 16,181
  • 3
  • 27
  • 36
1

The sample code already provided is good but I also do it this way and just get the hierarchical name of the server:

Set s = New NotesSession
Set db = s.CurrentDatabase
If db.Server <> "" Then
   Set sName = New NotesName(db.Server)
Else
   Set sName = New NotesName(s.Username)
End If
ServerName = sName.Abbreviated
0

Gary's answer is the most appropriate. You can actually identify the server name using hierarchical syntax to.

dim session as new notesSession
dim strCurrServer as string
dim nmServer as notesName

strCurrServer = session.currentagent.servername
' this bit is optional 
set nmServer = new notesName(strCurrServer)
' then you can do stuff like this
print nmServer.Abbreviated   

That would be the fastest (dirtiest?) way to get the server name from the webquery open agent. The notesName class is a handy object for dealing with hierarchical names link text

angryITguy
  • 9,332
  • 8
  • 54
  • 82
-3
'initialize event of a WebQueryOpen agent

Dim s As New notessession   
Dim servername As String
servername = s.UserName
  • `s.UserName` is not reliable: the code may be running as a web user, or under a special signing Notes ID< in which case you wouldn't be getting the actual server name from this call. – Ben Mar 02 '10 at 10:01