Type Mismatch

I have the following code which is erroring out for me on the following line of code. Any ideas as to what I’m doing wrong? Currently neither tmp or Assignees have values or display in debugger. I guess because the document hasn’t actually been saved yet.

Thanks,

error on this line

If docCurrent.IsNewNote Or tmp <> docCurrent.Assignees Then

Dim db As NotesDatabase

Set db = session.CurrentDatabase

'Assign variables

Dim IssueNum As String

Dim SendTo_1 As Variant

Dim agent As NotesAgent



Set agent = db.GetAgent("Set Sequential Number")

Call agent.run

Dim docCurrent As NotesDocument

Set docCurrent = uidoc.Document

Dim tmp As String

Dim Assignees As String



If docCurrent.IsNewNote Or tmp <> docCurrent.Assignees Then

	docCurrent.Form = "Memo" 

	Call ws.DialogBox( "dlgTest", True, True, True, False, False, False, "Message Content Only") 

	Call docCurrent.save(False, True )

	docCurrent.Subject = docCurrent.Subject_1

	docCurrent.Body = docCurrent.Body1

	Call docCurrent.send(False)

	

End If

End Sub

Subject: Type Mismatch

Hi Angie,

ahould it be:

docCurrent.Assignees(0)=“”

instead of

docCurrent.Assignees?

Subject: RE: Type Mismatch

Thanks File Save!!That resolved the error which I was receiving. Can you tell me what significance the (0) has? Is it indicating the first element of an array or another reason?

My code is still not doing what I want it to do. I’m selecting a document in a view and opening it for editing. Only if the Assignees field changes do I want the dialogbox to display. Right now the dialogbox is launched whether the same or different.

When viewing document properties on the existing docs I have a value in both tmp and Assignees fields. When viewing through debugger I have no values in either tmp or Assignees.

Any idea what else might be wrong with my code?

As always your help is GREATLY appreciated!

Subject: RE: Type Mismatch

in your original code you were testing as if doc.Assignees was a variant when it is not. To get the value of a single value text field or the 1st value of a multivalue field, you have to use doc.Assignees(0).

The second problem is the DialogBox.

You need to add a postmodechange event to store the current value of the assignees field into a temporary holding field (make it an editable hidden field).

When you do the Querysave, test the value of the Assignees field and if it is different than what is in the assignee field, kick off the dialog box. then clear the value of the hidden field.

PostModeChange:

Sub Postmodechange(Source As Notesuidocument)

dim doc as NotesDocument

set doc=source.document

if doc.Assignees(0) <>“” then

Call source.fieldsettext("tmpAssignees",

  Assignees(0))

end if

End Sub

in the Querysave

Sub Querysave(Source As Notesuidocument, Continue As Variant)

dim doc as NotesDocument

set doc=source.document

if doc.Assignees(0) <>doc.tmpAssignees(0) then

 'Do yourDialogthing	

end if

doc.tmpAssignees=“”

End Sub

Subject: Never mind, I’ve found my error.

I’ve made the changes as you’ve instructed but there is still something wrong. I’ve got the following code in the PostModeChange.

Sub Postmodechange(Source As Notesuidocument)

Dim docCurrent As NotesDocument

Set docCurrent=source.document

If docCurrent.Assignees(0) <>"" Then

	Call source.fieldsettext("tmpAssignees",Assignees)

End If

End Sub

The following code is in my QuerySave event

Sub Querysave(Source As Notesuidocument, Continue As Variant)

'Get a handle on the Notes Session

Dim session As New NotesSession

'Get a handle on the Current NotesUIWorkspace

Dim ws As New NotesUIWorkspace

'Get a handle on the uidoc and underlying document

Dim uidoc As NotesUIDocument

Set uidoc=ws.CurrentDocument

'Get a handle on the current database

Dim db As NotesDatabase

Set db = session.CurrentDatabase

'Assign variables

Dim IssueNum As String

Dim SendTo_1 As Variant

Dim agent As NotesAgent





Set agent = db.GetAgent("Set Sequential Number")

Call agent.run

Dim docCurrent As NotesDocument

Set docCurrent = uidoc.Document

Dim tmp As String

Dim Assignees As String

Call docCurrent.save(False, True )

If docCurrent.Assignees(0) <> docCurrent.tmpAssignees(0) Then

	'Do yourDialogthing 

	docCurrent.Form = "Memo" 

	Call ws.DialogBox( "dlgTest", True, True, True, False, False, False, "Message Content Only") 

	

	Call docCurrent.save(False, True )

End If

'docCurrent.tmpAssignees=""





docCurrent.Subject = docCurrent.Subject_1

docCurrent.Body = docCurrent.Body1

Call docCurrent.send(False)

End Sub

It seems that nothing I’m doing is setting the value for tmpAssignees. Thanks for your help!