Solved

Type Mismatch error

Posted on 2002-07-18
17
527 Views
Last Modified: 2013-12-18
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
0
Comment
Question by:pucktarget2
  • 8
  • 5
  • 4
17 Comments
 
LVL 5

Expert Comment

by:snocross
ID: 7162433
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?
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7162472
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
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 50 total points
ID: 7162507
Similarly, DateCheck(0) will contain the value of the field. So to find the difference between two dates use this routine

Set dt1= New NotesDateTime( "Today" )
Set dt2 = New NotesDateTime( Datecheck(0) )
diff = Abs(dt2.TimeDifference( dt1 ))
days = diff/86400
Print days

0
 

Author Comment

by:pucktarget2
ID: 7162705
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?
0
 

Author Comment

by:pucktarget2
ID: 7162707
Thanks again for some good code hemanth.
0
 

Author Comment

by:pucktarget2
ID: 7162749
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!
0
 

Author Comment

by:pucktarget2
ID: 7162752
I was able to fix the date value problem.

Puck
0
 
LVL 5

Expert Comment

by:snocross
ID: 7162758
You could use doc.created as in;

If StatusCheck<>doc.created Then
        Goto MoveOn
   End If
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 5

Expert Comment

by:snocross
ID: 7162775
Ok, disregard my comment then... a minute later..
0
 
LVL 5

Expert Comment

by:snocross
ID: 7162790
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)
0
 

Author Comment

by:pucktarget2
ID: 7162794
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
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7162856
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



0
 

Author Comment

by:pucktarget2
ID: 7164748
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
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7165350
Change the loop statement to check for the doc = nothing

DO
:
:
LOOP until doc is nothing
0
 

Author Comment

by:pucktarget2
ID: 7165515
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
0
 

Author Comment

by:pucktarget2
ID: 7165516
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
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 7165885
May be next time.

Thanks for the offer.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now