Populating Multiple field values to Single field

Hello All

I am populating the values of Multiple fields to a single field.

But in “CartItems” Field I am getting only the last “PartNo” which is generated dynamically.

How do I populate all the PartNo’s to CartItems field?

Please help me in coding…

here is my code

========================================

Sub Initialize

Dim session As New NotesSession 

Dim docSubmit As NotesDocument 

Dim varDocUNID As Variant 





Dim docSelected As NotesDocument 



Dim db As NotesDatabase 

Dim Parts As NotesItem

Dim Qty As NotesItem

Dim CartItems As NotesItem

'Get the document that was submitted with the embedded form

Set docSubmit = session.DocumentContext 

Set db = docSubmit.ParentDatabase 



path = Evaluate(|@LowerCase("/"+@ReplaceSubstring(@Subset(@DbName;-1);"\\";"/"))|,doc)



Print " <HEAD>"



Print "	</HEAD>"

Print |<BODY>| 

'Setup the web page's font 

Print |<Font Face="Verdana" size="2">|



Print "<H3><center>Bill of Materials</center></H3>"



'Get the field that contains the UNID's of the selected documents (array) 

varDocUNID = docSubmit.GetItemValue("$$SelectDoc")  



'Make sure that at least one document was selected 

If varDocUNID(0) = "" And Ubound(varDocUNID) = 0 Then 

	Print "No documents were selected.<BR>" 

Else 

	Print | <Form method="post" action="/dev/Quotes.nsf/FinalBOM?CreateDocument">|

	Print | <font face="Verdana" size="1">BOM ID : | 

	Print |<input type="text" name="BOM_Id"  size="20"></font>|

	

	

	Print "<BR><BR>" 

	Print | <TABLE border=".5" bordercolorlight="#000000" align="left" width="50%" cellpadding="5">|

	Print |<TR>|

	Print |<TH bgcolor="#F3F3F3"><font face="Verdana" size="1">Part No</font></TH>|

	Print |<TH bgcolor="#F3F3F3"><font face="Verdana" size="1">Quantity</font></TH>|

	Print |</TR>|

	

	'Loop through all the documents that were selected 

	Forall unid In varDocUNID 

		Set docSelected = db.GetDocumentByUNID(unid) 

		

		If Not docSelected Is Nothing Then 

			Print |<TR>|

			Print |<TD bgcolor="#EAF2FF" align="center"><font face="Verdana" size="1" >|&docSelected.PartNo(0)&|</font></TD>| 

			Print |<TD bgcolor="#EAF2FF" align="center"><font face="Verdana" size="1"> <input type="text" name="Qty"+docSelected.PartNo(0) size="6" ></font></TD>|

			Print |</TR>|

		End If

		

	End Forall 

	

	Print "</TABLE>"

	Print | <input type="text" name="CartItems" value="|&docSelected.PartNo(0)&|"> |   		

	Print |<Center><input type="button" value="View Materials" onClick="history.back();">

	<input type="submit" value="Save" onClick="document.body.innerHTML"> </Center>| ' "document.forms[0].elemrnts[0].submit()">

	Print | </Form> | 

	

	Print "</BODY>"

	Print "<BR><BR>" 

End If 



Print "<BR><BR>" 

End Sub

==========================================

Thanking You

Regards

Sanjay

Subject: RE: Populating Multiple field values to Single field

In the expression docSelected.PartNo(0), the (0) is an array index. You’re asking for only the first value in a multivalued item. To get all of them, try Join(docSelected.PartNo, “,”).

This question has been answered for you before less than a month ago: .

And if you don’t want the user to edit this field, use type=hidden.