Solved

Select server / directory

Posted on 2002-05-28
14
354 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
[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
  • 8
  • 5
14 Comments
 
LVL 10

Expert Comment

by:zvonko
ID: 7039929
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
ID: 7040184
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
ID: 7040213
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
Technology Partners: 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 10

Expert Comment

by:zvonko
ID: 7040230
Ok, and then... ???

0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 7040275
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
ID: 7040772
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
ID: 7040796
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
 
LVL 10

Expert Comment

by:zvonko
ID: 7040809
Good night Bro <|:-)

0
 
LVL 10

Expert Comment

by:zvonko
ID: 7041435
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
ID: 7041440
Oh boy you are for a biggie...2k for sure huh ?  Enjoy buddy !

:-)
Arun.
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7041584
I hope so :)

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

0
 

Author Comment

by:jvanhalderen
ID: 7041680
A++

RESPECT!! thnx a lot
0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 7042074
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
ID: 7042183
Yeapy!!!

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



0

Featured Post

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!

Question has a verified solution.

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

739 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