[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 359
  • Last Modified:

Select server / directory

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
jvanhalderen
Asked:
jvanhalderen
  • 8
  • 5
1 Solution
 
zvonkoCommented:
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
 
zvonkoCommented:
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
 
ArunkumarCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
zvonkoCommented:
Ok, and then... ???

0
 
ArunkumarCommented:
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
 
zvonkoCommented:
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
 
ArunkumarCommented:
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
 
zvonkoCommented:
Good night Bro <|:-)

0
 
zvonkoCommented:
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
 
ArunkumarCommented:
Oh boy you are for a biggie...2k for sure huh ?  Enjoy buddy !

:-)
Arun.
0
 
zvonkoCommented:
I hope so :)

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

0
 
jvanhalderenAuthor Commented:
A++

RESPECT!! thnx a lot
0
 
ArunkumarCommented:
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
 
zvonkoCommented:
Yeapy!!!

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



0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now