Solved

Select server / directory

Posted on 2002-05-28
14
347 Views
Last Modified: 2013-12-18
Hi all,

I created an agent that creates a new database. Now I'd like the user to select the destination of the database him/herself. So I need something that lists down all servers and directory on it but NOT the files.
Basicly I need the same pop-up as notes has when you select create new database. Formula or script I dont care.

@Prompt([ChooseDatabase]; "";"3") Wont work. because it shows the files as well.
0
Comment
Question by:jvanhalderen
  • 8
  • 5
14 Comments
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Is my assumption right: Notes client users, R5?

Any of the users has to be allowed to create databases on these servers. Are you aware of this? Most installation forbids such actions without Administrators.

On web it is no problem...



 
0
 
LVL 10

Accepted Solution

by:
zvonko earned 500 total points
Comment Utility
Hello,

here is my proposal.

I assume it has to run on Notes client.
I assume you want to have a button on a form (it is not a problem to transform to an action or an agent).
On this form there are also two text fields: ServerName and DatabasePath

Clicking on the button should allow selection of one of available servers (if field ServerName is empty). If then a server is selected a path list is assembled and a path can  be select from the list.

The code for this button is as follow:
Option Declare
Declare Function OSLockObject& Lib "nnotes" (Byval nHandle%)
Declare Function OSUnlockObject% Lib "nnotes" (Byval nHandle%)
Declare Function OSMemFree% Lib "nnotes" (Byval nHandle%)
Const OS_TRANSLATE_LMBCS_TO_NATIVE = 1
Const MAX_SERVER_NAME = 256
Declare Function NSGetServerList% Lib "nnotes" (Byval dwPortName&, nRetServerTextList%)
Declare Function ListGetText% Lib "nnotes" (Byval dwList&, Byval nPrefixDataType%, Byval nEntryNumber%, dwRetTextPointer&, nRetTextLength%)
Declare Function OSTranslate% Lib "nnotes" (Byval nTranslateMode%, Byval dwIn&, Byval nLength%, Byval lpszOut$, Byval nOutLength%)

Sub Click(Source As Button)
  Dim ws As New NotesUIWorkspace
  Dim uidoc As NotesUIDocument
  Dim ServerName As String
  Dim DatabasePath As String
 
  Set uidoc = ws.CurrentDocument
  ServerName = Trim$(uidoc.FieldGetText("ServerName"))
  If (ServerName = "") Then
    ServerName=GetServerName()
  End If
  If (ServerName = "") Then Exit Sub
  Call uidoc.FieldSetText("ServerName", ServerName)
 
  Dim session As New notessession
  Dim db As notesdatabase
  Dim dbdir As New NotesDbDirectory(ServerName)
  Dim path As String
  Dim ServerPaths() As String
  Dim isFound As Integer
  Set db = dbdir.GetFirstDatabase(DATABASE)
  Redim ServerPaths(0)
  While Not db Is Nothing
    path = Strleftback(db.filepath, "\")
    isFound = False
    Forall paths In ServerPaths
      If path = paths Then isFound = True
    End Forall
    If Not isFound Then
      Redim Preserve ServerPaths(Ubound(ServerPaths)+1)
      ServerPaths(Ubound(ServerPaths)-1) = path
    End If
    Set db = dbdir.GetnextDatabase
  Wend
  Redim Preserve ServerPaths(Ubound(ServerPaths)-1)
  DatabasePath = ws.Prompt(PROMPT_OKCANCELLIST, "Select Database Path", "Select one Database Path from the list.", "", ServerPaths)  
  If (DatabasePath <> "") Then Call uidoc.FieldSetText("DatabasePath", DatabasePath)
End Sub

Function GetServerName() As Variant
  Dim ws As New NotesUIWorkspace
  Dim ServerName As NotesName
  Dim lpszServer$
  Dim szArray() As String
  Dim hList%, nStatus%, nCount%, nLength%
  Dim dwList&, dwHold&
  nStatus%=NSGetServerList(0, hList%)
  If nStatus%=0 And hList% <> 0 Then
    Redim szArray(0)
    dwList&=OSLockObject(hList%)
    Do While nStatus%=0
      nStatus%=ListGetText(dwList&, 0, nCount%, dwHold&, nLength%)
      If nStatus%=0 And nLength%>0 Then
        lpszServer$=Space$(nLength%)
        Call OSTranslate(OS_TRANSLATE_LMBCS_TO_NATIVE, dwHold&, nLength%, lpszServer$, MAX_SERVER_NAME)
        Redim Preserve szArray(nCount)
        Set ServerName = New NotesName ( lpszServer$ )
        szArray(nCount)= ServerName.Abbreviated
      End If
      nCount=nCount+1
    Loop
    Call OSUnlockObject(hList%)
    Call OSMemFree(hList%)
  End If
  If Ubound(szArray) > 0 Then
    GetServerName = ws.Prompt(PROMPT_OKCANCELLIST, "Select Server", "Select one server from the list.", szArray(0), szArray)  
  End If
End Function

Good luck,
Zvonko


0
 
LVL 9

Expert Comment

by:Arunkumar
Comment Utility
Well, Cant you use the Directory's view of the servers and show in the promptlist ???

I am just curious....

To get the current server use the @Subset(@DbName ; 1)
You know the db name "names.nsf"
You will know the servers view is "Servers"
The column is 3

Why dont you do a @dbcolumn with all the parameters to get a list of all servers names and show it using an @Prompt list function ???

I am just curious.....

:-)
Arun.

0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Ok, and then... ???

0
 
LVL 9

Expert Comment

by:Arunkumar
Comment Utility
uh Oh !

I thought he needs only the servers. Now i got the whole point.

Hee Hee Hee !

Hold on guys i think we have an application running here. Let me c&p the code here !

;-)
Arun.
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Hello jvanhalderen,

from the history of your answered questions I see that you often give a B or even worse a C grading! This is not good.

The grading is not school grading; it is expert points multiplication factor.

So please give an A+ for my efforts. Thanks :-)

0
 
LVL 9

Expert Comment

by:Arunkumar
Comment Utility
You Beggar !

You Cheat !

You Bro !

I Like your approach anyways.... hee hee hee!

;-)
Arun
PS: Our app is completely different, this prompts to key in the directory...hmmmm....you win !
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Good night Bro <|:-)

0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Hello jvanhalderen,

if you have any questions about my code then ask them now.

I go sailing on Friday :-)

And please do not be so thrifty with your comments :)

If you do not like to write it in English then feel free to write to me in German, Bavarian, Serbo-Croatian, Macedonian or in Dutch to: paunoski@freenet.de

0
 
LVL 9

Expert Comment

by:Arunkumar
Comment Utility
Oh boy you are for a biggie...2k for sure huh ?  Enjoy buddy !

:-)
Arun.
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
I hope so :)

This vacations will move a lot of points from me to you :)

0
 

Author Comment

by:jvanhalderen
Comment Utility
A++

RESPECT!! thnx a lot
0
 
LVL 9

Expert Comment

by:Arunkumar
Comment Utility
That was an awesome grade for my Bro...

Thanks Jvanhalderen !  Few more like this to my buddy he will be on top of me ! Right Zvo ?

:-)
Arun.
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Yeapy!!!

Thanks jvanhalderen, for the points and for the feedback :-)



0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now