Populate Combobox

Hi

I want to populate a combo box field dynamically.

I’m reading a view, and until doc is not nothing I want to populate combo field with the doc.something(0).

something like this;

For i = 1 To notesDocumentCollection.Count

	Set docItemApp = notesDocumentCollection.GetNthDocument(i)

	Redim Preserve MapList(j)

	MapList(j) = docItemApp.ItemMap_Lst(0)		

	

	Call item.AppendToTextList(MapList)

	j = j + 1

Next



Call doc.ReplaceItemValue("ItemMatrix_Lst", MapList)

the last line command ReplaceItemValue is not working, why?

I’m coding on Postopen document.

Someone could help me pls ?

Regards!!

Subject: cringe

First of all, don’t use GetNthDocument(). It is SLOW.

I am not really clear on if you are trying to set the choices for the combobox or set the actual value. A combo box can not contain multiple values, you need to use a different kind of field for that, like a listbox.

If you want to set the different values that the user can choose from in the combo box (the options), you should use a separate multi-value text field, populate that with the values and then use a formula in the choices section of the combobox to get the values there.

Since the code is executing in PostOpen, you should update the uidoc, not the backend doc. That could be one reason it does not work.

You never declare/set the variable “item” to anything. It is also recommended not to use the extended syntax when getting values from documents, use GetItemValue() instead.

I would do it something like this:

Dim optionList As String

Set doc = col.GetFirstDocument()

Do Until doc Is Nothing

optionList = optionList + doc.GetItemvalue(“ItemMap_Lst”)(0) + “;”

Set doc = col.GetNextDocument(doc)

Loop

Call uidoc.FieldSetText(“ComboBoxOptionList”, optionList)

Call uidoc.Refresh()

Then you set the formula for the choices in your combobox to

@Explode(ComboBoxOptionList;“;”)

Make sure you set the property of the field to update choices document refresh.