VB and Secondary Data Sources - InfoPath Dev
in

InfoPath Dev

VB and Secondary Data Sources

Last post 08-25-2005 04:33 AM by Agni Jonnalagadda. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 08-20-2005 06:26 PM

    VB and Secondary Data Sources

    I am integrating InfoPath with Sharepoint and have several Secondary data sources. One of my secondary sources contains a field that I access to inside some Visual Basic code. To access a field on my main form I use:
    Dim projectType As IXMLDOMNode = e.XDocument.DOM.selectSingleNode
    ("/my:projectList/my:typeofProject")

    What is the equivalent code to access a field on a secondary data source named "Project Category"?

    Many thanks.

  • 08-21-2005 01:53 AM In reply to

    Re: VB and Secondary Data Sources

    Hi andywt,
    If it is a secondary DOM you need to get that dom and then select a node from that.
    You also have to set namespace property for that node

    Dim projectCategory As IXMLDOMDocument2 = e.XDocument.GetDOM("Project Category")
    projectCategory.setProperty("SelectionNamespaces", "Namespace")
    projectCategory.selectSingleNode("/my:projectList/my:typeofProject")

    //Namespace should have references to all namespaces used in that "Project Category" dataconnection

    Agni
    InfoPath Dev India
  • 08-21-2005 08:35 AM In reply to

    Re: VB and Secondary Data Sources

    Agni, Thanks for the help. One question on your reply. I did not have to explicitly set the namespace on the primary DOM, so why do I have yo on the secondary DOM?


    quote:
    Originally posted by Agni

    Hi andywt,
    If it is a secondary DOM you need to get that dom and then select a node from that.
    You also have to set namespace property for that node

    Dim projectCategory As IXMLDOMDocument2 = e.XDocument.GetDOM("Project Category")
    projectCategory.setProperty("SelectionNamespaces", "Namespace")
    projectCategory.selectSingleNode("/my:projectList/my:typeofProject")

    //Namespace should have references to all namespaces used in that "Project Category" dataconnection

    Agni
    InfoPath Dev India

  • 08-21-2005 08:57 AM In reply to

    Re: VB and Secondary Data Sources

    For primary DOM Namespace is set at the top of your code, this is taken care by Visual studio/InfoPath.
    You can see this it starts with "<InfoPathNamespace..."

    For secondary doms you have to take care of all those things.

    Agni
    InfoPath Dev India
  • 08-21-2005 09:34 AM In reply to

    Re: VB and Secondary Data Sources

    Thanks again you have been mose helpful. I am still a bit confused. My secondary source has a Infodath default structure of: myfields/mydata/ProjectCategory/Last_Used. To Dim "Last_Used" to use in my code would i do this?

    projectCategory.selectSingleNode("/my:myFields/my:dataFields/my:ProjectCategory)

    dim secField as IXMLDOMDocument2 = e.XDocument.DOM.selectSingleNode("/my:myFields/my:dataFields/my:ProjectCategory/my:Last_Used")


    quote:
    Originally posted by Agni

    For primary DOM Namespace is set at the top of your code, this is taken care by Visual studio/InfoPath.
    You can see this it starts with "<InfoPathNamespace..."

    For secondary doms you have to take care of all those things.

    Agni
    InfoPath Dev India

  • 08-21-2005 10:37 AM In reply to

    Re: VB and Secondary Data Sources

    You have to use
    dim secField as IXMLDOMDocument2 = e.XDocument.DOM.selectSingleNode("/my:myFields/my:dataFields/my:ProjectCategory/my:Last_Used")

    to select "Last_Used" node.


    Agni
    InfoPath Dev India
  • 08-21-2005 12:15 PM In reply to

    Re: VB and Secondary Data Sources

    Thanks again, however more questions, sorry to be so persistent. What I am ultimately trying to do is find the Last_Used field from the ProjectCategory secondary list that matched the ProjectCategoryCode (field from my Main Form), increment it by one and write the updated Last_Used back to my secondary data source.

    This is relatively straight forward within Infopath but I have to do it in VB code to insure that all the validation has occured.
    Here is what I have done based on your info, but VB does not like the way I was trying to do the query in the selectSingleNode. Any ideas?

    Dim LastUsed As IXMLDOMDocument2 = e.XDocument.GetDOM("Project Category")
    LastUsed.setProperty("SelectionNamespaces", "Namespace")
    LastUsed.selectSingleNode("/dfs:myFields/dfs:dataFields/dfs:ProjectCategory[@Project_Category='" & projectCategoryCode & "']")
    LastUsed.nodeTypedValue = LastUsed.nodeTypedValue + 1
    submit = thisXDocument.DataAdapters.Item("Submit ProjectUpdate")
    submit.Submit()


  • 08-25-2005 04:33 AM In reply to

    Re: VB and Secondary Data Sources

    Hi sorry for being late,
    You need to convert value into an integer before adding anything to it.

    Agni
    InfoPath Dev India
Page 1 of 1 (8 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.