Link to home
Start Free TrialLog in
Avatar of ajl7519
ajl7519

asked on

Best way to have reply emails entered into a Lotus Notes form document

Hello,

I have a ticketing database that I would like to setup so I can email from the ticket and when the user responds to have that information go directly into the ticket. Basically, I would to email directly from the ticket (I am assuming I can create a email form tied to the ticket) and to have thread documented into the ticket.

What would be the best way to accomplish this?

Thanks in advance..
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Sending mail is the easiest part, it's no big deal at all.

Receiving mail is a bit more difficult. What's important is that you understand the concepts, and then everything will automatically fall into its place:
- Notes/Domino has the concept of a Mail-in database: any database can be given a mail address
- mails received directly in the database always trigger the necessary agents (either Before or After mail arrived)
- the form used is always the Memo form (it's not a real form, it's just the name in the Form-field)
- the agent can convert the message to a more appropriate document in the database
- the agent can also try to figure out who the sender was, what the original message was (if any), so where the message should be attached
- an example could be the ticket number in the Subject field

Can you translate your problem into the above?
Additional thoughts:

I would make the responses into response documents to the original ticket.  You can then make them visisble using an embedded view or other means.

You can glean useful tips from the discussion template included with Notes, and don't forget OpenNTF:  It has tons of useful stuff, including a Help application which might save you a lot of work.
Avatar of ajl7519
ajl7519

ASKER

Well here is what I have for the Submit button. It will generate an email which includes the DocNumber, which is the ticket number. I also have similar emails go out when the ticket is assigned and then closed. The ticket number is generated by a hidden view and is sequential for each ticket. I have the messages being sent from another mail in database.

So what you are saying sjef_bosman is I can have an agent run based on the ticket number as it will be unique? What I would like to do is add an action button that would open up a new email form (I am assuming this could be a response document) for that would go out to the user. From there they would reply and I would need to tie that response document into the ticket?


Sub Click(Source As Button)
	
	Dim continue As Variant
	Dim workspace As New NotesUIWorkspace
	Dim session As New NotesSession
	Dim db As notesdatabase
	Dim maildoc As notesdocument
	Dim Body As NotesRichTextItem
	
	Dim uidoc As NotesUIDocument
	Dim doc As notesdocument
	Set uidoc = workspace.CurrentDocument
	Set doc=uidoc.document
	
	Dim valFields() As String
	Dim valcheck As String
	Redim valFields(6)
	valFields(0) =  "Laptop/Desktop/Blackberry"
	valFields(1) =  "Printer/Scanner/Copier/Fax"
	valFields(2) =  "Lotus Notes/Met Applications/Other Software"
	valFields(3) =  "VPN/Wireless/Connectivity"
	valFields(4) =  "Phone"
	valFields(5) =  "Move"
	valFields(6) =  "Generic Request"
	' loop through each valFields
	Forall xval In valFields
		valcheck = uidoc.FieldGetText("RequestType")
		If valcheck=  xval Then
			Goto Details
			continue = False
			Exit Sub
Details:
			If ( uidoc .FieldGetText( "Details" ) = "" ) Then
				Messagebox( "You must enter details of your request." )
				Call uidoc.GotoField( "Details" )
				continue = False
				Exit Sub
			End If
		End If
	End Forall
	
	Call uidoc.Save
	
     'Send mails:
	Set db=session.currentdatabase
	
	Set maildoc = New NotesDocument( db )
	maildoc.Form = "Memo"
	maildoc.From = doc.Requester(0)
	maildoc.SentBy = doc.Requester(0)
	maildoc.SendTo = "BFGSERVICEDESK"
	maildoc.Subject = "Request "+doc.DocNumber(0)+" submitted."              
	Set Body=New NotesRichTextItem(maildoc,"Body")
	message=  "New service request for "+doc.UserCN(0)
	Call Body.AppendText(message)
	Call Body.AddNewLine(1)
	message1= "Priority: "+doc.Priority(0)
	Call Body.AppendText(message1)
	Call Body.AddNewLine(1)
	message2= "Details: "+doc.Details(0)
	Call Body.AppendText(message2)
	Call Body.AddNewLine(2)
	message3="Please click this link to view this request=========>>"
	Call Body.AppendText(message3)
	Call Body.AppendDocLink(doc,"Please click this link to view this request")
	Call maildoc.Send( False) 
	
	Dim RequestSubmitted As String
	RequestSubmitted = "Your request has been submitted"
	Messagebox RequestSubmitted , MB_OK + MB_ICONINFORMATION, "Submitted"
	
	Call uidoc.Save
	Call uidoc.Close
	
End Sub

Open in new window

Avatar of ajl7519

ASKER

Also, I see what your saying about the embedded view. I would create the view for the response documents and embed into the ticket. I would then need a way to have view to show only the related documents and I suppose I can have script or formula do that.
simple:
the embedded view categorizes on the parent id.  in embeded view set show single category using DocumentUNID (==parentID)
I wouldn't use the UNID for that purpose, but the DocNumber, assuming it is unique for every ticket and can have multiple responses. An appropriate view with DocNumber as first column (sorted) will allow you to find your ticket document easily. Instead of generating a DocuNumber based on a view, you could use a code generated by @Unique (see the Help db).

> I have the messages being sent from another mail in database.
That puzzles me. Mails sent from a mail-in database? Am I being picky or was my explanation not clear enough? It is a mail-IN database, meaning that mails can be received by the database. Any database can send mails, there's nothing special about that. To receive mails in a database, you need to create a Mail-In Database document in the server's Address Book.
Avatar of ajl7519

ASKER

Well, the separate mail-in database was in place before and I was told to continue using. It's basically just a mailbox that handled the tickets. Also, it was requested that I have sequential numbers fro the ticket number (DocNumber).

Ok. So you could set the ticket database to receive mails. Of course you have to be prepared to get junk mail in there as well...
Sequential numbers: brr a world of pain. @Unique is actually a pretty good idea.
Avatar of ajl7519

ASKER

I wanted to use @Unique, but my boss wanted them sequential. I actually got a tip here how to do that. It works pretty well. I haven't had a problem as of yet.

Yes, I could set the ticketing database as mail-in.

Would it be possible to use it the existing way however? Let's say I create a mail form as a response document sent from the Mail-in database. I can tied that response into the view and filter by DocNumber. Would that work?
You have an agent that creates a response in your ticket database when a reply comes in? That would work, yes.

If it were my boss I'd generate those sequential numbers, just for him, but anywhere else I'd use an @Unique id, guaranteed to work even when replicating databases to other servers or clients. The sequential number would then just be that: a number, meaningless.
Avatar of ajl7519

ASKER

I think finally understand how to get it to work, but only problem I am having is getting the response document generated from the main document to pick up the fields from the main document. Do you need specific code to link the child document to parent document to accomplish this? Is there where I would use the @Unique to link the documents via a view lookup?

Thanks, I appreciated your help (patience) with Lotus. I basically am the only IT person for like 500 people (and I do absolutely everything from phones to computers) and I only have a hour or so a day to work on Lotus development.
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ajl7519

ASKER

I got it working. Thanks for you help.
I'm truly impressed....
Avatar of ajl7519

ASKER

This code picks up all the fields when I used the create mail action. Do you see any problems using it?


Sub Click(Source As Button)
	Dim ws As New notesuiworkspace
	Dim uidoc As notesuidocument
	Dim session As New notessession
	Dim db As notesdatabase
	Dim pdoc As notesdocument
	Dim cdoc As notesdocument
	
	Set uidoc = ws.currentdocument
	Set pdoc = uidoc.document
	Set db = session.currentDatabase
	Set cdoc = db.createDocument
	
	cdoc.Form = "Mail" 
	cdoc.MStatus = pdoc.StatusChange(0)
	cdoc.MDocNumber = pdoc.DocNumber(0)
	cdoc.SendTo= pdoc.Requester(0)
	Call cdoc.makeResponse(pdoc)
	Set uidoc = ws.EditDocument(True, cdoc)
End Sub

Open in new window

Looks good to me but... for this you don't need code at all, it can be done using standard Notes features:
1/ Define the form type as a Response form (1st tab, 3rd line)
2/ Enable "Formulas inherit values from selected document" on the 2nd tab in the Form Properties
That's why we love Notes!  All the built-ins that save us time!