Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / April 2005

Tip: Looking for answers? Try searching our database.

Programatically add row to a repeating table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mauricio - 15 Apr 2005 00:36 GMT
Hi,

I want to add a new row programatically to a repeating table.
I'm working with FormCode.cs class of .net framework to programming. I've
created IXMLElement to add to IXMLNode object that represents the repeating
table.

i.e.:
IXMLDOMNode docData =
thisXDocument.DOM.selectSingleNode("//my:DocumentsData");
IXMLDOMElement proc = thisXDocument.DOM.createElement("Process");
docData.appendChild(proc);

When Infopath forms runs, a message exception like:
System.Runtime.InteropServices.COMException
Element 'Process' is unexpected according to content model of parent element
'{http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-03-02T18:37:11}Docu
mentsData
'.
Expecting:
{http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-03-02T18:37:11}Process.

Anyone have any idea???
DocumentData Expects Process element, and i pass a process element, but it
does not recongnize.

Any pointers would be really appreciated.
Regards,
Mauricio.-
KjellSJ - 29 Apr 2005 13:20 GMT
Your problems stems from your XSD using a <sequence> of elements, and the
node you try to append to the end of your XML is not of the same type as the
last element in your XSD.

You cannot append a 'DocumentsData' element at the end, only 'Process'
elements according to your XSD.

Use node.insertBefore instead of node.appendChild (JScript code):

//get first row
var rowOne = XDocument.DOM.selectSingleNode("//s1:InvoiceDetailsRow");
//clone the first row
var rowClone = rowOne.cloneNode(true);
//reset values
rowClone.selectSingleNode("s1:Description").text = "CLONED";
rowClone.selectSingleNode("s1:NetAmount").text = "";
rowClone.selectSingleNode("s1:IsVatCharged").text = 0;
rowClone.selectSingleNode("s1:VatAmount").text = 0;
//append row to XML document
var parent =
XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields//s1:Invoice");
parent.insertBefore(rowClone, rowOne);       

   
Hope this helps!
KjellSJ (http://kjellsj.blogspot.com)

> Hi,
>
[quoted text clipped - 23 lines]
> Regards,
> Mauricio.-
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.