GetItemValue doesn't return any value

I’m trying to access the Lotus Notes 6.0 Contacts from IE 6.0 using vbscript. following is my code:

Dim objNotesSession

set objNotesSession = CreateObject(“Notes.NotesSession”)

Dim objNotesDB, objNotesView, objNotesDoc, objContact

Dim fname, lname, email

call objNotesSession.initialize(“”)

Set objNotesDB = objNotesSession.GetDatabase(“”, “names.nsf”)

Call objNotesDB.Open

Set objNotesView = objNotesDB.GetView(“Contacts”)

Set objNotesDoc = objNotesView.GetFirstDocument()

If objNotesDoc.HasItem(“FirstName”) Then

  fname = objNotesDoc.GetItemValue("FirstName")(0)

end if

If objContact.HasItem(“LastName”) Then

  lname = objContact.GetItemValue("LastName")(0)

end if

If objContact.HasItem(“MailAddress”) Then

  email = objContact.GetItemValue("MailAddress")(0)

end if

my problem is there are no value return from any of the property. i checked my lotus notes contacts and all values are in place (Document Properties). What am i doing wrong? or what could i do to get first name, last name, email value back?

Thanks in advance.

Subject: GetItemValue doesn’t return any value

Asa,

Are you running against a local workspace or the server? If the server, I’m not familiar with ‘Contacts’ view in the public N&A Book.

regards,

raphael

Subject: RE: GetItemValue doesn’t return any value

it is running against local workspace.

the script, since it is access from web page, is vbscript, and therefore cannot declare variable “as string”

I’ve also tried objNotesDoc.FirstName(0) and get the same result.

Subject: RE: GetItemValue doesn’t return any value

Are you sure that you have some contact documents in your local workspace? If you want to try that, try accessing the views: “People” or “$Users” in the names.nsf on a server.

Subject: RE: GetItemValue doesn’t return any value

sorry, do you mean objNotesDoc.GetView(“People”) or objNotesDoc.GetView(“$Users”)?

thanks.

Subject: RE: GetItemValue doesn’t return any value

Yes. Try those views from the names.nsf which is on server.

objNotesSession.GetDatabase(“Your Server”, “names.nsf”)

Subject: RE: GetItemValue doesn’t return any value

tried it, and the same behavior…

Subject: FOUND IT!!!

Hi there,

i had the same problem and i was very near to kill somebody…

But, in the last second, i found the solution:

The GetItemValue returns an array which seems not to be compatible with vbscript! Try this instead:

yourdoc.GetFirstItem(“itemname”).Text

sure, multivalue fields are not very funny, because the values are joined with ; to one string, but you will get some values back…

For me, its all i want :slight_smile:

Subject: GetItemValue doesn’t return any value

Declare these as strings:

Dim fname as string, lname as string, email as string