XPath query with parameter - InfoPath Dev
in

InfoPath Dev

XPath query with parameter

Last post 05-17-2010 09:30 AM by bryanstrader. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-14-2010 11:30 AM

    XPath query with parameter

    Here is what I am trying to do in my expression box: Companies[@ID = 6]/@Name However, instead of using the number 6 as my parameter for the ID, i would like to query from the main data source. So I think it should be something like this: xdXDocument:GetDOM("ClientInformationDC")/dfs:myFields/dfs:dataFields/d:Companies[@ID = my:myFields/my:ClientInformation/my:CompanyID]/@Name Basically I have the id stored in my main data source, and need to use it to get the company name from my secondary data source. It doesn't appear to like the fact that I am in a sense "joining" data sources. It doesn't seem to like the "my:myFields/my:ClientInformation/my:CompanyID" expression because I am already looking at another data source.
    Bryan Strader
    Software Developer
  • 05-14-2010 07:40 PM In reply to

    Re: XPath query with parameter

     To have XPath reference the main data source when it is already in the context of another, you can use xdXDocument:get-DOM():

      xdXDocument:GetDOM("ClientInformationDC")/dfs:myFields/dfs:dataFields/d:Companies[@ID = xdXDocument:get-DOM()/my:myFields/my:ClientInformation/my:CompanyID]/@Name

    InfoPath will usually do this for you if you use the Select Field... button, though I think sometimes it won't be smart enough to figure out you're going back and forth between data sources.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 05-17-2010 09:30 AM In reply to

    Re: XPath query with parameter

    That is exactly what I was looking for. Thanks Jimmy. I didn't know xdXDocument:get-DOM() was something that was available to me in the expression boxes.

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