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 / November 2005

Tip: Looking for answers? Try searching our database.

Problem with coding repeating section

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul Webster - 22 Nov 2005 18:09 GMT
I have written some C# code to update a field with a value from a
secondary data source when a related field is selected in a drop down
list. This works fine, except when the fields are held in a repeating
section. It works for the first instance of the section, however not if
I insert any further occurrences.
I guess that I have to get current() into the code somehow, however I
cannot work ou how.
Can anyone help?

//Update the unit field with the unit held on the secondary source for
the selected product

IXMLDOMNode NodeUnit =
thisXDocument.DOM.selectSingleNode("/ABWOrder/Order/Details/Detail/UnitCode");
IXMLDOMNode NodeProduct =
thisXDocument.DOM.selectSingleNode("/ABWOrder/Order/Details/Detail/BuyerProductCode");
IMLDOMDocument3 oSecondDoc =
(IXMLDOMDocument3)thisXDocument.DataObjects["GetPermProducts"].DOM;
oSecondDoc.setProperty("SelectionNamespaces",
"xmlns:s0=\"OPD\"
xmlns:dfs=\"http://schemas.microsoft.com/office/infopath/2003/dataFormSolution\"

xmlns:my=\"http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-11-22T13:55:56\"

xmlns:xd=\"http://schemas.microsoft.com/office/infopath/2003\"");

IXMLDOMNodeList oNodeList =
oSecondDoc.selectNodes("/dfs:myFields/dfs:dataFields/s0:GetPermProductsResponse/s0:GetPermProductsResult/NewDataSet/products");
foreach (IXMLDOMNode oN in oNodeList)
{
if(oN.selectSingleNode("article").nodeTypedValue.ToString()==NodeProduct.nodeTypedValue.ToString())
{                           
NodeUnit.nodeTypedValue=oN.selectSingleNode("unit_code").nodeTypedValue;
}
}
Paul Webster - 22 Nov 2005 18:28 GMT
Sorry, that didn't format very well. I hope that this is better.

IXMLDOMNode
NodeUnit=thisXDocument.DOM.selectSingleNode("./ABWOrder/Order/Details/Detail/UnitCode");

IXMLDOMNode NodeProduct
=thisXDocument.DOM.selectSingleNode("./ABWOrder/Order/Details/Detail/BuyerPro
ductCode");

IXMLDOMDocument3 oSecondDoc
=(IXMLDOMDocument3)thisXDocument.DataObjects["GetPermProducts"].DOM;

oSecondDoc.setProperty("SelectionNamespaces","xmlns:s0=\"OPD\"xmlns:dfs=\"
etc. etc.

IXMLDOMNodeList oNodeList =
oSecondDoc.selectNodes("/dfs:myFields/dfs:dataFields/s0:GetPermProductsRespo
nse/s0:GetPermProductsResult/NewDataSet/products");

foreach (IXMLDOMNode oN in oNodeList)
   {
       if(oN.selectSingleNode("article").nodeTypedValue.ToString() ==
              NodeProduct.nodeTypedValue.ToString())
                     {
                           NodeUnit.nodeTypedValue =

oN.selectSingleNode("unit_code").nodeTypedValue;
                     }

    }
Franck Dauché - 22 Nov 2005 19:31 GMT
Hi Paul,

when you select your nodes from your main DOM, you need to point to:
IXMLDOMNode oNode =
thisXDocument.DOM.selectSingleNode("/my:myFields/my:group1/my:group2[n]");
where n if the instance and in your case, group1 = Details and group2
(repeating) = Detail.  You can increment n by 1 in your foreach.

Hope that it helps.

Regards,

Franck Dauché

> Sorry, that didn't format very well. I hope that this is better.
>
[quoted text clipped - 26 lines]
>
>      }
 
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.