Link to home
Start Free TrialLog in
Avatar of pucktarget2
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.GetItemValue("txtStatus")
     DateCheck=doc.GetItemValue("txtMaturityDate")
     
(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.CreateDocument
               If memo Is Nothing Then
                    SendError = "SendNotification:  Unable To Assign Memo"
                    ErrorOccurred = True
               End If
               
               Set Body = memo.CreateRichTextItem("Body")
               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=KeyCorp"
               memo.From = "CN=NE GL Comml Paids/OU=GL/OU=KB/O=KeyCorp"
               Call rtitem.AppendDocLink(doc,"OARF")
               memo.Subject = "Officer Acknowledgement Release Form"
               memo.SendTo=doc.FieldGetText("txtOfficerEMail")
               Set Status=doc.ReplaceItemValue("txtStatus","Second Request")
               Call memo.Send(False)
               
MoveOn:
               Set doc = view.GetNextDocument(doc)
          End If
     Loop
End Sub
Avatar of snocross
snocross

Ok, assuming the text field contains an actual date (ie: "October 8, 1996") you could do something like this:

If StatusCheck<>DateValue(NewReq) Then
         Goto MoveOn
    End If

Can you try this and let me know what happens?
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
ASKER CERTIFIED SOLUTION
Avatar of HemanthaKumar
HemanthaKumar

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 pucktarget2

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?
Thanks again for some good code hemanth.
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!
I was able to fix the date value problem.

Puck
You could use doc.created as in;

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)
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
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



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
Change the loop statement to check for the doc = nothing

DO
:
:
LOOP until doc is nothing
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.CreateDocument
               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.CreateDocument
               If memo Is Nothing Then
                    SendError = "SendNotification:  Unable To Assign Memo"
                    ErrorOccurred = True
               End If
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
May be next time.

Thanks for the offer.