Wednesday, January 11, 2012

Iterate through InfoPath 2007 Repeater Table to get the values Programatically

I had a task to iterate through the repeater table of InfoPath 2007 form and get all the values entered by user on submit.

Here is a vb.net code

Imports Microsoft.Office.InfoPath

'' ********** Upload multiple attachments **************
Public Sub btnUploadAllAttachments_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

Dim xPathNavigator As XPathNavigator = MainDataSource.CreateNavigator()

Dim rows As XPathNodeIterator = xPathNavigator.Select("/my:ShowCauseForm/my:ShowCauseDetails/my:AttchmentsTable/my:AttachmentRow", NamespaceManager)

While rows.MoveNext()

Upload(rows.Current.SelectSingleNode("my:Attachment", NamespaceManager).Value, "/my:ShowCauseForm/my:ShowCauseDetails/my:HyperLinkSection/my:AttachmentUrl", "Attachment")
End While

Windows.Forms.MessageBox.Show("All attachments uploaded successfully", "Attachments Upload", MessageBoxButtons.OK)

End Sub

No comments: