Choose Database to Open

Hello,

I have ticketing system that creates tickets from emails. I have a function that can get it to open my database and select an email, but I would like to be able to choose between my mail database and another one (ticketing mail in database). Here is the code I have now that works with my mail file.

Any suggestions?

Thanks in advance.



Public Function CreateFromMail ( strView As String ) As Boolean
		
		CreateFromMail = False
		
		Dim uiws As New NotesUIWorkspace 
		Dim s As New NotesSession 
		Dim dbThis As NotesDatabase 
		Dim item As NotesItem
		Dim rtitem As NotesRichTextItem 		
		Dim dbMail As NotesDatabase 
		Dim docMail As NotesDocument 
		Dim docTicket As NotesDocument
		Dim collMail As NotesDocumentCollection 
		Dim namesfield As Variant
		Dim notesDatabase As NotesDatabase
		
		Set dbThis = s.CurrentDatabase 
		Set dbMail = Nothing 
		
		Set dbMail = New NotesDatabase("","") 
		Call dbMail.OpenMail
		If Not dbMail.IsOpen Then Error 1001, "Could not open user's mailfile" 
		
		Set collMail = uiws.PickListCollection ( PICKLIST_CUSTOM, False, dbMail.Server, dbMail.FilePath, _ 
		strView, "Transform Mail To Ticket", "Please select an e-Mail: ") 
		If collMail.Count = 0 Then Exit Function  'No document selected 
		Set docMail = collMail.GetFirstDocument    
		Set docTicket = Me.Create
		
		Set item = docTicket.ReplaceItemValue ( "TransformMail", "1" )
		Set item = docTicket.ReplaceItemValue ( "EnteredBy", "0" )
		Set item = docMail.GetFirstItem( "Subject" )
		Set item = docTicket.ReplaceItemValue ( "Problem", item.text )
		Set item = docMail.GetFirstItem( "From" ) 
		Set item = docTicket.ReplaceItemValue ( "user", item.text )

Open in new window

LVL 1
ajl7519Asked:
Who is Participating?
 
mbonaciCommented:
Yes, you can alter that function:
Function ChooseDb( flgRaiseError As Boolean ) As NotesDatabase
	Dim w As New NotesUIWorkspace
	Dim s As New NotesSession
	Dim arr(1) As String
	Dim ret As Variant

	arr(0) = "Mail database"
	arr(1) = "Ticketing database"

	ret = w.Prompt( 4, "Database selection", "Choose the Lotus database", arr(0), arr )

	If Isempty( ret ) Then 
	If flgRaiseError Then
			Messagebox "User canceled", , "Database not selected" : Exit Sub
		Else
			Exit Function
		End If
	Else
		If CStr(ret) = "Mail database" Then
			Set ChooseDb = New NotesDatabase("","") 
			Call ChooseDb.OpenMail
		Else
			Set ChooseDb = s.GetDatabase( "ticketing_server", "ticketing_path", False )
		End If
	End If

End Function

Open in new window

0
 
mbonaciCommented:
use this function to prompt the user to choose a db:


Function ChooseDb( flgRaiseError As Boolean ) As NotesDatabase
	Dim w As New NotesUIWorkspace
	Dim s As New NotesSession
	Dim ret As Variant
	
	ret = w.Prompt( 13, "Database selection", "Choose the Lotus database" )
	If Isempty( ret ) Then 
		If flgRaiseError Then
			Messagebox "User canceled", , "Database not selected" : Exit Sub
		Else
			Exit Function
		End If
	Else
		Set ChooseDb = s.GetDatabase( ret(0), ret(1), False )
	End If

End Function

Open in new window

0
 
mbonaciCommented:
So, instead of these two lines in your code:

            Set dbMail = New NotesDatabase("","")
            Call dbMail.OpenMail

use this line (after you paste the function to Form's Declarations section):

            Set dbMail = ChooseDb( True )
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
mbonaciCommented:
Or, if you want to hard-code ticketing mail in database in another function use this line to get db:

    Set db = s.GetDatabase( serverName, dbPath, False )

See here for details:
http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.designer.domino.main.doc/H_GETDATABASE_METHOD.html
0
 
ajl7519Author Commented:
This works fine, but is there a way to get it to choose between my mail and the mail in database with this function?


Function ChooseDb( flgRaiseError As Boolean ) As NotesDatabase
	Dim w As New NotesUIWorkspace
	Dim s As New NotesSession
	Dim ret As Variant
	
	ret = w.Prompt( 13, "Database selection", "Choose the Lotus database" )
	If Isempty( ret ) Then 
		If flgRaiseError Then
			Messagebox "User canceled", , "Database not selected" : Exit Sub
		Else
			Exit Function
		End If
	Else
		Set ChooseDb = s.GetDatabase( ret(0), ret(1), False )
	End If

End Function

Open in new window

0
 
Sjef BosmanGroupware ConsultantCommented:
Maybe I don't understand, but why don't you (tell people to) forward a mail to the Ticket database, where an agent picks it up and converts it automatically??
0
 
ajl7519Author Commented:
"Maybe I don't understand, but why don't you (tell people to) forward a mail to the Ticket database, where an agent picks it up and converts it automatically?"

That is how it works now. I select Transform from Mail>Ticket, but it defaults to my mailbox where as I want to choose between my mailbox and the ticket database mailbox.
0
 
Sjef BosmanGroupware ConsultantCommented:
Maybe I still don't understand...

How it could work:
- a mail is sent to ticket@yourplace.abc, which is the name of the ticket mail-in db
- the mail arrives directly in the mail-in db tickets.nsf
- directly after receiving the mail, an agent picks it up and converts it to a ticket

Where comes your code in? Who needs to select a database??
0
 
ajl7519Author Commented:
I think I will use a InputBox and GoTo method, but what is the code to open a database other than the current database? I was looking and I see that maybe I can use the GetDatabase method, but not sure where to go from there or of the correct syntax. I see there is a NoteDBDirectory option as well.

Set db = s.GetDatabase("OtherServer","OtherMailFile.nsf")

Thanks
0
 
mbonaciCommented:
InputBox and GoTo? Why on earth would you do that?
Haven't you tried the function I posted in my last post?

As far as your other question, about opening a database, is concerned, haven't you seen this line:
    Set ChooseDb = s.GetDatabase( "ticketing_server", "ticketing_path", False )

Don't forget to enter correct values instead of "ticketing_server" and "ticketing_path".
See here about specifying server and db path:
    http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.designer.domino.main.doc/H_GETDATABASE_METHOD.html
0
 
ajl7519Author Commented:
First off thanks for you help mbonaci.

I added your function. and replaced

Set dbMail = New NotesDatabase("","")
Call dbMail.OpenMail

with

Set dbMail = ChooseDb( True )

I get a the below the error.

Missing argument for: CHOOSEDB on the below line
                        
Call ChooseDb.OpenMail




0
 
Sjef BosmanGroupware ConsultantCommented:
I get the impression that your Lotus Notes development skills are not sufficient to complete this task. Ask a professional in your neighbourhood to help you out.
0
 
ajl7519Author Commented:
Yes, I am new to Lotus Notes. I will figure it out and post back when it works.
0
 
ajl7519Author Commented:
I figured it out. I just built your code into the original function. This works now. Thanks.


Public Function CreateFromMail ( strView As String ) As Boolean
		
		CreateFromMail = False
		
		Dim uiws As New NotesUIWorkspace 
		Dim s As New NotesSession 
		Dim dbThis As NotesDatabase 
		Dim item As NotesItem
		Dim rtitem As NotesRichTextItem 		
		Dim dbMail As NotesDatabase 
		Dim docMail As NotesDocument 
		Dim docTicket As NotesDocument
		Dim collMail As NotesDocumentCollection 
		Dim namesfield As Variant
		Dim arr(1) As String
		Dim ret As Variant
		Dim flgRaiseError As Boolean
		
		arr(0) = "Mail database"
		arr(1) = "Ticketing database"
		
		ret = uiws.Prompt( 4, "Database selection", "Choose the Lotus database", arr(0), arr )
		
		If Isempty( ret ) Then 
			If flgRaiseError Then
				Messagebox "User canceled", , "Database not selected" 
			Else
				Exit Function
			End If
		Else
			If Cstr(ret) = "Mail database" Then
				Set dbThis = s.CurrentDatabase 
				Set dbMail = Nothing 
				
				Set dbMail = New NotesDatabase("","") 
				Call dbMail.OpenMail 
				If Not dbMail.IsOpen Then Error 1001, "Could not open user's mailfile" 
			Else
				Set dbMail = s.GetDatabase( "Server", "Path", False )
				If Not dbMail.IsOpen Then Error 1001, "Could not open user's mailfile" 
			End If
		End If

Open in new window

0
 
Sjef BosmanGroupware ConsultantCommented:
Excellent!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.