Using a field's text value to build an XPath expression - InfoPath Dev
in

InfoPath Dev

Using a field's text value to build an XPath expression

Last post 11-19-2009 10:54 PM by fschick. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 11-19-2009 08:09 PM

    Using a field's text value to build an XPath expression

    Hi,

    This is my first post on this site.  I have been designing forms in infopath for about 18 months and have found this site incredibly valuable when I had questions in the past.  I have not been able to find any info on how to do what I am trying to do without code, which I am very sure could be done, but I would prefer not to use code or manually set filters in the data source dialogs.  (when using code I use VB or JScript.. fyi)

    I am creating a form that will permit our salespeople to quote our customers.  When quoting this particular class of product, we only permit one of these products to be quoted per form.

    Short Question:  What i want to do is take the text value of a listbox control, concat it with another string and match that value to a column name to find the boolean value(s) in that column = TRUE

    Long Question:

    1. I have a dropdown listbox listing the products available in this quote.  this control is named PRODUCTS and it has 3 items whose names & values are: 'Product1', 'Product2', and 'Product3'
    2. I have a database in Access (I may convert it into a MS SQL 2005 db)
      • This db has multiple tables, each table acts as a logical grouping of available components for all three products.  eg:  a table named 'Valves' that has 10 rows in it.  Some valves are used by Product1, some are used by Product2, some are used by Product3 or any combination of any or all of them.
      • Each table has 3 indexed, boolean columns.  for purposes of this post they are named: 'Product1_avail', 'Product2_avail', and 'Product3_avail'.  If a component in the table has a TRUE value in one of these columns, it is a component that can be added to that particular product chosen in the 1st
    3. What I want to do is take the text value from the listbox (lets say Product1) and perform concat(./PRODUCTS, "_avail"), the result of which would correspond to a column name.  in this case, 'Product1_avail'.
    4. Then take that string value to choose the corresponding data column and return all rows whose values in that column which are marked as TRUE
    5. So, the XPath would look something like this (i believe):   ../@(concat(xdXDocument:get-DOM()/my:myFields/my:PRODUCTS/text(), "_avail")) = "TRUE"   I know that ' ../@(concat ' is not valid XPath. I'm looking for a solution that is valid XPath.
    Is there a non-code solution using only XPath expressions?

    If you need more info, please post your requests.

    Thanks A Lot!

     

  • 11-19-2009 08:34 PM In reply to

    Re: Using a field's text value to build an XPath expression

    Qdabra just released qRules v2.0 with the new Set Value command that does exactly what you have in mind. It filters a repeating table based on an xpath parameter that you create based on other fields. qRules includes a collection of the most common InfoPath commands that would require code. You can inject qRules into your form and just set the qRules secondary data source to execute the command you want. You can use InfoPath rules do this. Here's a link to more information: http://www.qdabra.com/en/products/qRules.aspx

    Patrick Halstead
    Project Manager at Qdabra
  • 11-19-2009 09:09 PM In reply to

    Re: Using a field's text value to build an XPath expression

     qRules is great when you want to set a value in a single row of a repeating section, but if I understand correctly, you're trying to retrieve values based on a dynamic XPath query.

    In this case, I think something like this should work:

     ../@*[local-name() =concat(xdXDocument:get-DOM()/my:myFields/my:PRODUCTS/text(), "_avail")] = "TRUE"

    You should double-check that the true values are actually TRUE, and not 'true' (lower case) or '1'.  I would expect it to be one of the latter.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 11-19-2009 10:54 PM In reply to

    Re: Using a field's text value to build an XPath expression

     Jimmy:

    Thanks a lot.  you put me on the right track.  I figured out exactly what I needed after about 20 min of trial & error.

    Your help saved me a grip of time.

    MUCH APPRECIATED!

     

    -Fritz

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