Multi values and lotus script

I am using a lotus script agent to create a new document from a open document all works great but when I try to bring values from a field that has multiple values the script only picks up the first value. Will lotus script bring over multiple values, or is there another way to do this? As I mentioned all other field values are saved in the new document as expected.

The code is very straight forward

i.e. newdoc.multivalue = olddoc.multivalue(0)

The field I am trying to populate is a checkbox, multi value allowed. When you view in agent with the scripted debugger you see only the first value, and it is passed to the new document.

Subject: ALL fields in LotusScript are multivalue…

Andre had the right advice for you. Just as an FYI ALL fields from a document access in LotusScript are treated as an array. Thus your attempt to access olddoc.multivalue(0). the (0) means the zero (or first) instance of a zero based multivalue array. Since you are creating a new document on the back end a simple assignment such as Andre suggested will work. If you ever need to process against all elements in a multivalue field you should use some kind of loop.

eg

For i = 0 to Ubound(olddoc.multivalue)

seeThis = olddoc.multivalue(i)

Next

Will loop through all elements in teh multivalue field and set them to the seeThis variable one at a time.

HTH

Subject: multi values and lotus script

Also, see the LotusScript “arrayreplace” and “arrayappend” functions.

Subject: multi values and lotus script

Mark,The advice from Andre Guirard won’t work. It will give you an error.

If you think about it you need to do the following:

newdoc.itemvalue(0) = olddoc.olditemvalue(0)

newdoc.itemvalue(1) = olddoc.olditemvalue(1)

newdoc.itemvalue(2) = olddoc.olditemvalue(2)

newdoc.itemvalue(3) = olddoc.olditemvalue(3)

and so on until there no more values in olditemvalue.

I have done this before, but to give you a hint, get the olditemvalue’s and put them into an Array, them move the array one element at a time to the itemvalue’s.

Regards

Rolf Pfotenhauer

Subject: Have you ever tried it? It sure does work and works correctly.

Your example on the other hand will NOT work. You can PULL sepecific elements from a field i.e.fourthval = doc.FieldName(3)

but you can not assign values i.e.

doc.FieldName(3) = fourthval

Subject: RE: multi values and lotus script

Well, leave off the array index that says you just want the first value and you should be OK, e.g.:

newdoc.multivalue = olddoc.multivalue

Subject: multi values and lotus script

i belive this should work

newdoc.ReplaceItemValue “newitemname”, olddoc.GetItemValue(“olditemname”)

Subject: sheesh just do this Call notesItem.CopyItemToDocument( document, newName$ )

here’s the rest of the help on it … dont take my word though its right in the Designer help

Dim session As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim memo As NotesDocument

Dim itemA As NotesItem

Dim itemB As NotesItem

Set db = session.CurrentDatabase

'…set value of doc…

Set itemA = doc.GetFirstItem( “Body” )

Set itemB = doc.GetFirstItem( “BriefDescription” )

Set memo = New NotesDocument( db )

Call itemA.CopyItemToDocument( memo, “Body” )

Call itemB.CopyItemToDocument( memo, “Subject” )

Call memo.Send( False, “Cynthia Brainey” )