Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Iterating thru items in a database

Status
Not open for further replies.

rturnbul

Technical User
Feb 6, 2005
6
US
Hi,

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)
Wend

askme = ws.Prompt(PROMPT_OKCANCELLISTMULT, "Select a Name", "Select one or more names as recipients for this request.",input(1) , input)
 
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 :
Code:
@DbColumn("":"";"":"";viewname;1)
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.

Pascal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top