I’m running into a problem with an agent I created. This agent basically takes the information from a form and sends it in an email after it is saved. I have the form and agent working on the client, however after throwing in some error trapping, I noticed that the agent for some reason isn’t processing right on the web. I’m creating a Nab view to pull the email addresses of where the email should be sent, based on a field chosen in this form, however based on the error trapping I put in, it’s not even finding the view or matching the keyword to the view. Here’s the agent. I’d greatly appreciate any help!
Sub Initialize( )
Dim session As New NotesSession
Dim db As NotesDatabase
Dim mailDoc As NotesDocument
Dim nameItem As NotesItem
Dim doc As NotesDocument
Dim lookupStr As String
Dim nabDb As NotesDatabase, nabView As NotesView
Dim nabDoc As NotesDocument
Dim FormName, FromName As String
Dim SubjectName, SendToName As String
Dim nam As NotesName, nameStr As String
Dim CopyToName As String
Dim rtItem As NotesRichTextItem
Set doc = session.DocumentContext
lookupStr = doc.GetItemValue("applications")(0)
Set nabDb = session.CurrentDatabase
Set nabView = nabDb.GetView("(AppData)")
Set nabDoc = nabView.GetDocumentByKey(lookupStr)
If Not(nabDoc Is Nothing) Then
Set nameItem = nabDoc.GetFirstItem("manager")
'Set nam = nameItem.Values("manager")
Forall x In nameItem.Values
nameStr = Cstr(x)
End Forall
Set nam = session.CreateName(nameStr)
If doc.GetItemValue("status")(0) = "New" Then
FormName = "Memo"
FromName = doc.GetItemValue("filed_by")(0)
SubjectName = "New Access Change"
SendToName = nam.Common
Set db = session.CurrentDatabase
Set mailDoc = db.CreateDocument
Set rtItem =mailDoc .CreateRichTextItem("Body")
With rtItem
Call .AppendText("There is a system access change request.")
Call .AddNewline(2)
Call .AppendText(doc.filed_by(0) + " filed the following system access change: " + doc.change(0))
Call .AddNewLine(2)
Call .AppendText("Employee: " + doc.employee(0))
Call .AddNewline(2)
Call .AppendText("Application: " + doc.applications(0))
End With
With mailDoc
.Form = FormName
.From = FromName
.Subject = SubjectName
.SendTo = SendToName
.Send(False)
End With
Else
FormName = "Memo"
FromName = "Mark Rankin"
SubjectName = " Access Change Update For: " + doc.GetItemValue("employee")(0)
SendToName = doc.GetItemValue("filed_by")(0)
CopyToName = nam.Common
Set db = session.CurrentDatabase
Set mailDoc = db.CreateDocument
Set rtItem =mailDoc .CreateRichTextItem("Body")
With rtItem
Call .AppendText("The following system access change request has been completed.")
Call .AddNewline(2)
Call .AppendText("Access Change: " + doc.change(0))
Call .AddNewLine(2)
Call .AppendText("Employee: " + doc.employee(0))
Call .AddNewline(2)
Call .AppendText("Application: " + doc.applications(0))
End With
With mailDoc
.Form = FormName
.From = FromName
.Subject = SubjectName
.SendTo = SendToName
.CopyTo = CopyToName
.Send(False)
End With
End If
Else
Set db = session.CurrentDatabase
Set mailDoc = db.CreateDocument
Set rtItem =mailDoc .CreateRichTextItem("Body")
With rtItem
Call .AppendText("There is a error with system access change request application.")
Call .AddNewline(2)
End With
With mailDoc
.Form = "Memo"
.From = "mrankin@rpminc.com"
.Subject = "Error"
.SendTo = "mrankin@rpminc.com"
.Send(False)
End With
End If
End Sub