I am trying to change a multivalue field. I achieve this, when multivalue
field or value being assigned is empty, or I assign values of the same
quantity. (ie there are 3 values in the field and I assign a 3 values array,
it works).
But when the quantity of values does not match (ie array being assigned has
2, or 4 or ... values), I do see assignment in debugger, but when I return
to document, there's nothing changed.
I use following code in a click event of a button:
Dim anArray As Variant
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
anArray = doc.MultivalueField
' ... Some processing here with anArray ...
uidoc.EditMode = True
doc.MultivalueField = anArray
also I tried following assignment (instead of last line in previous)
Dim item As NotesItem
Set item = doc.GetFirstItem("MultivalueField")
Item.Values = anArray
Result is always exactly the same.
What do I do wrong???
Best regards, Alex.
P.S. When I write
doc.MultivalueField = EMPTY
doc.MultivalueField = anArray
the 1st assignment works, but 2nd does not - I become empty field, when
quantities do not match.
check the designer help on ReDim. this will probably help you out.
cheers rob
> check the designer help on ReDim. this will probably help you out.
could you please explain what do you mean? do i have to redimension the
field value?
i don't manage that, with redim at least
Another example can be found within the TableWalker template. Likely
to be found within the Notes.net Sandbox downloads.
Cheers Rob
If you don't know how many elements are going to be in the array, you
are going to have to use a dynamic array. That's where the ReDim
keyword comes in. Used in conjunction with the Preserve keyword you
can resize arrays on the fly. To write an array to a field use a
Forall loop with the AppendToTextList method of notesItem
aList = doc.List
count = Ubound (aList)
Redim Preserve aList (count + 1)
aList (count + 1) = doc.NewItem(0)
doc.List = aList
****
forall elements in aList
Call item.AppendToTextList( elements )
end forall
call doc.Save
or be slick and use the Evaluate method:
doc.List = Evaluate ( {List : NewItem}, doc)
The Designer Help should have enought o get you going.
HTH,
JLucien
due to "StringFellow" I have found correct answer:
i must use ReplaceItemValue, then it works.
Thanx to all.
v = Doc.GetItemValue("Field")
and than you have v(0) v(1) ...
Peter
forall m in anArray
call Item.AppendToTextList(m)
end forall
call uidoc.reload