[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4441
  • Last Modified:

How to use VBscript to read a Lotus Notes Database

Hi,
I am not able to read a Lotus Notes Database by a VBscript. The beginning of the code is sussessful
Set session = CreateObject("Notes.NotesSession")
Set DestDb = session.GetDatabase("server", "my.nsf")
Set XDb = DestDb.GetView("MyView")
Set XDoc = XDb.GetFirstDocument()
subj = XDoc.Getitemvalue("Address")

no error so far, I want to read all information in the field "Address". How to continue the code?
0
oxn
Asked:
oxn
  • 3
  • 2
1 Solution
 
Bill-HansonCommented:
If the field "Address" is a multi-value field, then you are done.  Your 'subj' variable should be an array of values contained by the field.

  ex: subj = XDoc.Getitemvalue("Address")

If the field "Address" is a single-value field, use the array index operator to extract the first value in the field since Notes fields are accessed like arrays (except rich text).

  ex: subj = XDoc.Getitemvalue("Address")(0)
0
 
oxnAuthor Commented:
The subj = XDoc.Getitemvalue("Address")(0) return error.
In Lotus Notes i found that "Address"  -  Data Type: Text
Is this rich text? How to read rich text?
0
 
Bill-HansonCommented:
What is the error message?  How is the 'subj' variable defined?

If the field type is 'Text', that is regular old plain-text.  Does the field have "Allow multiple values" checked?
0
 
oxnAuthor Commented:
The error message is: Type mismatch:'Getitemvalue(...)'
The variable subj is defined
Dim subj
The documents properties for Address:
Field Name: Address
Data Type: Text
Data Length: 5 bytes
Seq Num: 1
Dup Item ID: 0
Field Flags: SUMMARY

I'm able to read a field with property Data Type: Time/Date - using For Each loop
but not Data Type: Text. Any suggestion to solve this problem?
0
 
Bill-HansonCommented:
OK, found it.

Apparently, VBScript has trouble reading Notes value arrays (which is what is returned by GetItemValue).

Instead, get a handle to the 'Subject' NotesItem using GetFirstItem, then read the item's Text property.

Try this...
Set session = CreateObject("Notes.NotesSession")
Set DestDb = session.GetDatabase("server", "my.nsf")
Set XDb = DestDb.GetView("MyView")
Set XDoc = XDb.GetFirstDocument()
subj = XDoc.GetFirstItem("Subject").Text

Open in new window

0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

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