• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3005
  • Last Modified:

Lotus Notes GetItemValue = Type Mismatch using VBScript

Basically I've looked everywhere for this, and my code appears to be correct.
I've tried using:
arrName = fDoc.Getitemvalue("PC_Name")(0)
But that errors with a Type Mismatch

Using:
arrName = fDoc.Getitemvalue("PC_Name")
Does work and puts the data in, but then I try to access it and get type mismatch.

I tried doing:
wscript.echo fUNID(0)
and that works.
But replace it with arrName(0) and I get a type mismatch.

In the variable window, they are both exactly the same, and both contain 1 string value (0)
The data IS there, as I can see in the variable window, that the correct data is showing up under arrName(0)

I've tried Dimming, but as I'm not using option explicit that doesn't matter I don't think.
Any ideas?

Set notessession = CreateObject("Notes.Notessession")
Set notesdb = notessession.GetDatabase("SERVER", "DATABASE.nsf")
 
Set notesView = notesdb.getview("VIEW NAME")
Set fDoc = notesView.getFirstDocument
 
i = 0
Set fDoc = notesView.GetFirstDocument
ReDim fUNID(0)
Do While Not fDoc Is Nothing
	
	ReDim Preserve fUNID(i)
	fUNID(i) = fDoc.UniversalID
						
	arrName = fDoc.Getitemvalue("PC_Name")
         wscript.echo arrName(0)     'ERROR IS HERE
 
	Set fDoc = notesView.GetNextdocument(fDoc)
	i=i+1
Loop

Open in new window

0
CreepyD
Asked:
CreepyD
  • 2
1 Solution
 
qwaleteeCommented:
Try this
Do While Not fDoc Is Nothing
	ReDim Preserve fUNID(i)
	fUNID(i) = fDoc.UniversalID
						
	Set arrItem = fDoc.GetFirstItem("LastName")
	arrName = arrItem.Text
         wscript.echo arrName
 
	Set fDoc = notesView.GetNextdocument(fDoc)
	i=i+1
Loop

Open in new window

0
 
Sjef BosmanGroupware ConsultantCommented:
Or this, converting explicitly to a string-type:
        arrName = fDoc.Getitemvalue("PC_Name")
        wscript.echo CStr(arrName(0))

Open in new window

0
 
qwaleteeCommented:
Sjef, that also gives a type mismatch.  For some reason, VBS has a devil of a time dealing with Notes value arrays. WHether you get them via implicit attributes of the document, getItemValue, or getItem(...).Values, you can assign it, but you can't do anything with it.

See here http://www-10.lotus.com/ldd/nd6forum.nsf/0/72d14e06c0a90e76852572820054459b
0
 
CreepyDAuthor Commented:
Thanks, that link is perfect!
It was certainly weird being able to assign it and see the data, but not do anything with it.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now