Getting info to secondary data source when the dataconnection returns an xml document - InfoPath Dev
in

InfoPath Dev

Getting info to secondary data source when the dataconnection returns an xml document

Last post 08-06-2009 02:21 PM by Patrick Halstead. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 08-05-2009 07:31 AM

    Getting info to secondary data source when the dataconnection returns an xml document

    Let me first say this is a great forum.

     Here is the problem I have: when I create the dataconnection it obviously doesn't create the nodes in the secondary data source that contain the xml document.  The secondary data source is uneditable, but I believe I know how to make it edible.  Do I need to add to manually add the nodes to the secondary data source in order to map these values to controls bound to nodes to the primary data source or is there an easier better way to do this?  I hope this makes sense.

    So when I use code like below it compiles fine, but the dc does not contain any information about the nodes in the XmlDocument that has been returned.

    XPathNavigator yo = DataSources["DI_GetDIDoc"].CreateNavigator();

    yo.SelectSingleNode("/dfs:myFields/dfs:queryFields/ns2:DI_GetDIDoc/ns2:strSDNum", NamespaceManager).SetValue("140695");

    DataConnection dc = this.DataConnections["DI_GetDIDoc"];

    dc.Execute();

         

     

  • 08-06-2009 02:21 PM In reply to

    Re: Getting info to secondary data source when the dataconnection returns an xml document

    Hi Witzer and thanks for the complement,

    I'm not sure I understand your scenario exactly, so here's a few points:

    • A good Web Service will return the correct WSDL for the data and you won't have to do any parsing of strings... In other words, you'll see the XML show up in the data source pane if you select the data connection you added and expand the nodes.
    • Sometimes, you need to send it a value so that it will return the correct schema. Use the sample value for that when you create the connection. Make sure the Web Service returns a plural number of rows for repeating data sets so that your form identifies it as repeating. If you don't have control over the Web Service, this can be a problem.
    • The DC is just the data connection. To get the secondary data you need to select the nodes you want. For example:

    XPathNavigator sourceTable = domSource.SelectSingleNode(tablesrc);
    XPathNavigator sourceRow = sourceTable.SelectSingleNode(rowsrc);
    XPathNodeIterator srcNodes = sourceTable.Select(rowsrc, FormHost.NamespaceManager);

    Assuming the DC returns the correct XML structure (not sure about that from what you said), you should take a look at qRules 1.7 (free). It has a CopyTable function that lets you copy nodes from a secondary data source into your main data source. No coding required.

    Cheers

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.