Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Iterating thru items in a database

Iterating thru items in a database

Iterating thru items in a database


I am trying to iterate thru all documents of a database(mydb.nsf)
I want to gather all of the values of an item (LastName)
Question:  How do I build an (array of strings, I think).  This will become the input for a prompt so a user can choose something.

Part of my code listing shown below ...

code to setup environment ....

Dim db As NotesDatabase
Set db =s.GetDatabase("NotesServer","mydb.nsf",False)
Set collection = db.AllDocuments
Set doc = collection.GetFirstDocument()
While Not doc Is Nothing    
    mylist = doc.GetItemValue("LastName")
     Forall x In mylist
    Messagebox x
** need to insert missing code here to build array
     End Forall

    Set doc = collection.GetNextDocument(doc)    
    askme = ws.Prompt(PROMPT_OKCANCELLISTMULT, "Select a Name", "Select one or more names as recipients for this request.",input(1) , input)

RE: Iterating thru items in a database

Unless all of your documents have a LastName field, this sounds not too good to me. Even if all docs do have the field, you're going to be swamped with duplicates and your list is not going to be very useful.
I would suggest building a view (or using an already built one if it works) that lists all docs with the field, and categorizes them in the first column. That way, you have a unique list available.
Then, and this is a bit sneaky, make a hidden form with one field on it. Make the field computed, and give it a formula like this :


Where viewname is obviously the name of your unique name view.
Now, all you have to do to retrieve the list is create a dummy doc in your code, assign the form name to your hidden form, use the computewithForm method and you have your list in the field.
All that is left is to assign the item values to a variant, and then you can call your prompt.

Now that we have been through all this, are you sure you have to do this in Script ? A Formula with a PickList would have been a lot easier.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close