views:

1188

answers:

5

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

+1  A: 
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
Derek
A: 
'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 Poole
A: 

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
A: 

Thanks. It helped

A: 

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

giulio