Solved

Type Mismatch error

Posted on 2002-07-18
17
531 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Bulk lotus notes account creation 3 82
Formula for Barcode Scanning within Excel 2010 3 68
Open Sans serif font rounded version 3 186
Issues with Word font 4 83
For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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…

773 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