XpathNavigator - Secondary Datasource - InfoPath Dev
in

InfoPath Dev

XpathNavigator - Secondary Datasource

Last post 03-09-2008 09:37 AM by knudde. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-07-2008 03:07 PM

    XpathNavigator - Secondary Datasource

    I'm new to infopath 2007 but I'm devloping a a form that have a Main DS and a Secondary DS to a SharePoint List

     

    The goal here is to have the user select a Firm (Firm_Name) and them populate the Account Id (Pfx_ID) problem I recieve an error from this code:

    Public Sub Firm_Name_Changed(ByVal sender As Object, ByVal e As XmlEventArgs)

    ' Write your code here to change the main data source.

    Dim XpathFirmName As String = "/my:myFields/my:Customer_Information/my:Firm_Name"

    Dim strDataSource2 As String = "Project Information"

    ' Get a reference to the Project Information secondary data source,

    ' and create an XPathNavigator object for it.

    Dim XpathNav2 As XPathNavigator = Me.DataSources(strDataSource2).CreateNavigator

    ' Create an XPathNavigator object positioned on the current site,

    ' which is the Select FirmName node in the main data source.

    Dim XpathNavMain As XPathNavigator = e.Site.CreateNavigator

    ' Move to the parent of the SelectCustomer node, so that the code

    ' can access the FirmName node.

    XpathNavMain.MoveToParent()

    Dim selectedCustomer As String = XpathNavMain.SelectSingleNode(XpathFirmName, Me.NamespaceManager).ToString

    Dim strQuery As String = "/dfs:myFields/dfs:dataFields/dfs:Project_Information[@Firm_Name='" & e.Site.InnerXml & "']/Pfx_ID"

    Dim PFXid As string = XpathNav2.SelectSingleNode(strQuery, Me.NamespaceManager).InnerXML

     

    My secondary problem is that there is actually a chance that a Firm will have 2 entries in the Project_Information datasource. In which case I need to populate a Second Dropdown list for them to select "/Project_Id" then finally populate a textbox with the creation_date.  

     

     

     

     

     

  • 03-08-2008 06:40 PM In reply to

    Re: XpathNavigator - Secondary Datasource

    sorry the error I'm getting is "dsf namespace not defined"

  • 03-09-2008 09:37 AM In reply to

    Re: XpathNavigator - Secondary Datasource

     Hi,

     correct me if i'm wrong (never used 2007) but i thinkyou need to define the namespace before you can start working with it

     

    Infopath 2003 code 

     var websobj=XDocument.DataObjects["list_machines"] ;     //list_machines is the name of my secondary data service

    websDOM=websobj.DOM

    websDOM.setProperty("SelectionNamespaces",'xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:ns2="http://tempuri.org/"');

     

     

    Dim XpathNav2 As XPathNavigator = Me.DataSources(strDataSource2).CreateNavigator

    here you specify your secondayr datasource but you don't tell infopath what namespace to use, hence the dfs (dataformsolution) error i think
     

    KriZ
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.