pucktarget2
asked on
Type Mismatch error
Hello all. I am trying to evaluate documents in a notes collection. I need to look at two fields on the document in the notes collection to determine if I need to send a notification out. One is a date field, and the other is a text field.
I am getting an error when the two values are attempting to compare to each other.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim view As NotesView
Dim selection As String
Dim doc As NotesDocument
Dim StatusCheck As Variant
Dim DateCheck As Variant
Dim vartest As Variant
Dim Memo As NotesDocument
Dim Body As NotesRichTextItem
Dim rtitem As NotesRichTextItem
Dim richStyle As NotesRichTextStyle
Dim NextOARF As String
Dim NewReq As Variant
Set db=session.CurrentDatabase
Set view=db.GetView("OARF Processing Queue")
Set doc = view.GetFirstDocument()
NewReq="New Request"
StatusCheck=doc.GetItemVal ue("txtSta tus")
DateCheck=doc.GetItemValue ("txtMatur ityDate")
(FIRST ERROR IS HERE!) Type mismatch error.
If StatusCheck<>NewReq Then
Goto MoveOn
End If
Do
(I am guessing it will also hit an error here, but have not gotten that far yet.)
vartest=DateCheck-Date()
If vartest>14 Then
Set memo = s.currentdatabase.CreateDo cument
If memo Is Nothing Then
SendError = "SendNotification: Unable To Assign Memo"
ErrorOccurred = True
End If
Set Body = memo.CreateRichTextItem("B ody")
If Body Is Nothing Then
SendError = "SendNotification: Unable To Assign Body"
ErrorOccurred = True
End If
Set richStyle = s.CreateRichTextStyle
If richStyle Is Nothing Then
SendError = "SendNotification: Unable To Assign RichTextStyle"
ErrorOccurred = True
End If
richStyle.NotesFont = FONT_HELV
richStyle.Bold = True
richStyle.Underline = False
richStyle.FontSize = 12
richStyle.NotesColor = COLOR_BLACK
Call Body.AppendStyle(richStyle )
Call Body.AddNewLine(1)
Call Body.AppendText("OARF Form submitted for your approval, please click on link above to view and approve or reject request.")
richStyle.NotesFont = FONT_HELV
richStyle.Bold = True
richStyle.Underline = False
richStyle.FontSize = 14
richStyle.NotesColor = COLOR_RED
Call Body.AppendStyle(richStyle )
Call Body.AddNewLine(1)
Call Body.AppendText("NOTE: This is your second notification. Loan Services will not release collateral on paid loans until OARF form has been confirmed.")
Set rtitem=New NotesRichTextItem(memo, "Body")
memo.Principal = "CN=NE_GL Comml Paids/OU=GL/OU=KB/O=KeyCor p"
memo.From = "CN=NE GL Comml Paids/OU=GL/OU=KB/O=KeyCor p"
Call rtitem.AppendDocLink(doc," OARF")
memo.Subject = "Officer Acknowledgement Release Form"
memo.SendTo=doc.FieldGetTe xt("txtOff icerEMail" )
Set Status=doc.ReplaceItemValu e("txtStat us","Secon d Request")
Call memo.Send(False)
MoveOn:
Set doc = view.GetNextDocument(doc)
End If
Loop
End Sub
I am getting an error when the two values are attempting to compare to each other.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim view As NotesView
Dim selection As String
Dim doc As NotesDocument
Dim StatusCheck As Variant
Dim DateCheck As Variant
Dim vartest As Variant
Dim Memo As NotesDocument
Dim Body As NotesRichTextItem
Dim rtitem As NotesRichTextItem
Dim richStyle As NotesRichTextStyle
Dim NextOARF As String
Dim NewReq As Variant
Set db=session.CurrentDatabase
Set view=db.GetView("OARF Processing Queue")
Set doc = view.GetFirstDocument()
NewReq="New Request"
StatusCheck=doc.GetItemVal
DateCheck=doc.GetItemValue
(FIRST ERROR IS HERE!) Type mismatch error.
If StatusCheck<>NewReq Then
Goto MoveOn
End If
Do
(I am guessing it will also hit an error here, but have not gotten that far yet.)
vartest=DateCheck-Date()
If vartest>14 Then
Set memo = s.currentdatabase.CreateDo
If memo Is Nothing Then
SendError = "SendNotification: Unable To Assign Memo"
ErrorOccurred = True
End If
Set Body = memo.CreateRichTextItem("B
If Body Is Nothing Then
SendError = "SendNotification: Unable To Assign Body"
ErrorOccurred = True
End If
Set richStyle = s.CreateRichTextStyle
If richStyle Is Nothing Then
SendError = "SendNotification: Unable To Assign RichTextStyle"
ErrorOccurred = True
End If
richStyle.NotesFont = FONT_HELV
richStyle.Bold = True
richStyle.Underline = False
richStyle.FontSize = 12
richStyle.NotesColor = COLOR_BLACK
Call Body.AppendStyle(richStyle
Call Body.AddNewLine(1)
Call Body.AppendText("OARF Form submitted for your approval, please click on link above to view and approve or reject request.")
richStyle.NotesFont = FONT_HELV
richStyle.Bold = True
richStyle.Underline = False
richStyle.FontSize = 14
richStyle.NotesColor = COLOR_RED
Call Body.AppendStyle(richStyle
Call Body.AddNewLine(1)
Call Body.AppendText("NOTE: This is your second notification. Loan Services will not release collateral on paid loans until OARF form has been confirmed.")
Set rtitem=New NotesRichTextItem(memo, "Body")
memo.Principal = "CN=NE_GL Comml Paids/OU=GL/OU=KB/O=KeyCor
memo.From = "CN=NE GL Comml Paids/OU=GL/OU=KB/O=KeyCor
Call rtitem.AppendDocLink(doc,"
memo.Subject = "Officer Acknowledgement Release Form"
memo.SendTo=doc.FieldGetTe
Set Status=doc.ReplaceItemValu
Call memo.Send(False)
MoveOn:
Set doc = view.GetNextDocument(doc)
End If
Loop
End Sub
Hello Puck,
GetItemValue will return the value in a array, if it is a single value the value will be refered at index 0, so your code becomes
If StatusCheck(0) <> NewReq Then
Goto MoveOn
End If
~Hemanth
GetItemValue will return the value in a array, if it is a single value the value will be refered at index 0, so your code becomes
If StatusCheck(0) <> NewReq Then
Goto MoveOn
End If
~Hemanth
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I can get past the New Request eval. Having trouble with the date. It is pulling a null value from the field I am referencing on the form. Can I pull the create date somehow?
ASKER
Thanks again for some good code hemanth.
ASKER
I get an "Function requires a valid ADT argument. " error when running this agent.
It happens at the end of the do just before the loop at this code:
Set doc = view.GetNextDocument(doc)
Thanks!
It happens at the end of the do just before the loop at this code:
Set doc = view.GetNextDocument(doc)
Thanks!
ASKER
I was able to fix the date value problem.
Puck
Puck
You could use doc.created as in;
If StatusCheck<>doc.created Then
Goto MoveOn
End If
If StatusCheck<>doc.created Then
Goto MoveOn
End If
Ok, disregard my comment then... a minute later..
I think you need to change your DO statement to handle when there is no longer a document for example:
Do While not (Doc is Nothing)
Do While not (Doc is Nothing)
ASKER
Thanks again Hemanth. I am getting a little better at understanding notes code. Quick follow-up. Is my loop going to stop or will it know to exit once it reaches the end of the document collection.
Puck
Puck
Your loop doesn't seem to handle the document = nothing exception
So you might have to put this block of script in a while loop like this
Set doc = view.GetFirstDocument
While not doc is nothing
............
' Do this block
............
Set doc = view.GetNextDocument(doc)
Wend
So you might have to put this block of script in a while loop like this
Set doc = view.GetFirstDocument
While not doc is nothing
............
' Do this block
............
Set doc = view.GetNextDocument(doc)
Wend
ASKER
Nothing seems to work. I looks like it is not changing to a null value after hitting the last document so then it just keeps looping over the last document over and over again.
Puck
Puck
Change the loop statement to check for the doc = nothing
DO
:
:
LOOP until doc is nothing
DO
:
:
LOOP until doc is nothing
ASKER
Thanks Hemanth....using your Loop Until doc is nothing helped me find the problem. Doc was never equaling nothing because the loop was going over the getnextdocument command from this point:
If days<>14 Then
Set memo = s.currentdatabase.CreateDo cument
If memo Is Nothing Then
SendError = "SendNotification: Unable To Assign Memo"
ErrorOccurred = True
End If
It would skip to the end if after the set doc = view.getnextdocument. This meant is never read zero. I changed it to this and it worked:
If days<>14 Then
Goto MoveOn
Else
Set memo = s.currentdatabase.CreateDo cument
If memo Is Nothing Then
SendError = "SendNotification: Unable To Assign Memo"
ErrorOccurred = True
End If
If days<>14 Then
Set memo = s.currentdatabase.CreateDo
If memo Is Nothing Then
SendError = "SendNotification: Unable To Assign Memo"
ErrorOccurred = True
End If
It would skip to the end if after the set doc = view.getnextdocument. This meant is never read zero. I changed it to this and it worked:
If days<>14 Then
Goto MoveOn
Else
Set memo = s.currentdatabase.CreateDo
If memo Is Nothing Then
SendError = "SendNotification: Unable To Assign Memo"
ErrorOccurred = True
End If
ASKER
Hemanth.....I want to give you some extra point for the help. Or do you just want me to make it up to you next time?
Thanks again.
Puck
Thanks again.
Puck
May be next time.
Thanks for the offer.
Thanks for the offer.
If StatusCheck<>DateValue(New
Goto MoveOn
End If
Can you try this and let me know what happens?