Using current() to filter results to a specific table row (node) - InfoPath Dev
in

InfoPath Dev

Using current() to filter results to a specific table row (node)

Last post 09-08-2015 02:40 PM by mcharnell. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 08-26-2015 05:23 PM

    • mcharnell
    • Not Ranked
    • Joined on 08-01-2014
    • Vancouver, BC
    • Posts 15

    Using current() to filter results to a specific table row (node)

    Hi All, I have recently upgraded from Infopath 2007 and Sharepoint 2007 to the 2013 versions.

    I had a repeating table where users entered a date, expense type, and cost of an expense. The expense type came from a Sharepoint library called Expense GL's.

    Previously I was able to set a 4th field called GL based on the Expense Type the user selected and the company there were from. The old xpath code looked like this:

    xdXDocument:GetDOM("Expense GLs")/dfs:myFields/dfs:dataFields/dfs:Expense_GLs/@GL[../@Company = xdXDocument:get-DOM()/my:myFields/my:Company and ../@Title = current()/../my:Expense_type]

    However I cannot get the function current() to work in the new Infopath form to filter the result to the current row (node).
    I have tried putting current() everywhere but it won't work. Here is what I have so far.

    xdXDocument:GetDOM("Expense GLs")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:GL[../d:Company = xdXDocument:get-DOM()/my:myFields/my:Company and ../d:Title = xdXDocument:get-DOM()/my:myFields/my:Expenses_Sec/my:Expenses/my:Expense_Items/my:Expense_type]

    I would expect to put current() right after the ../d:Title = but this does not work. Any thoughts?

  • 08-27-2015 08:17 AM In reply to

    Re: Using current() to filter results to a specific table row (node)

     So - you are using this expression where? On the Expense Type field?

    Hilary Stoupa

  • 08-27-2015 08:20 AM In reply to

    • mcharnell
    • Not Ranked
    • Joined on 08-01-2014
    • Vancouver, BC
    • Posts 15

    Re: Using current() to filter results to a specific table row (node)

     Yes that is correct.  I want to select the value of the Expense Type field for the current row.

  • 08-27-2015 08:33 AM In reply to

    Re: Using current() to filter results to a specific table row (node)

     If the rule is on the actual expense type field, I'd guess:
    xdXDocument:GetDOM("Expense GLs")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:GL[../d:Company = xdXDocument:get-DOM()/my:myFields/my:Company and ../d:Title = current()]

    If the rule instead is on the Main Data Source repeating table row, I'd guess:
    xdXDocument:GetDOM("Expense GLs")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:GL[../d:Company = xdXDocument:get-DOM()/my:myFields/my:Company and ../d:Title=current()/my:Expense_type] 

    Feel free to attach your form under the Options tab with a hint about where to look for the logic if you'd like a hand. 

    Hilary Stoupa

  • 08-27-2015 09:21 AM In reply to

    • mcharnell
    • Not Ranked
    • Joined on 08-01-2014
    • Vancouver, BC
    • Posts 15

    Re: Using current() to filter results to a specific table row (node)

    I have attached the form. 

     

     I am trying to set the value of the field GL_Code found /my:myFields/my:Expenses_Sec/my:Expenses/my:Expense_Items/

    The field should equal the GL field from the Expense GLs sharepoint library where the company name on the form and the company name for the GL match, as well as where the Expense_type in the current row of the repeating table on the form matches the Title field of the item in the Expense Gls library.

    I did try adding current() where you suggested but it needed the whole path of the Expense_type field for some reason so it looked like this: 

     xdXDocument:GetDOM("Expense GLs")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:GL[../d:Company = xdXDocument:get-DOM()/my:myFields/my:Company and ../d:Title = current()xdXDocument:get-DOM()/my:myFields/my:Expenses_Sec/my:Expenses/my:Expense_Items/my:Expense_type]

    ..but there is a syntax error somewhere. 

  • 09-08-2015 02:16 PM In reply to

    Re: Using current() to filter results to a specific table row (node)

     I didn't realize you were using a default value on GL Code instead of a rule on Expense Type. Try this for your default value:

    xdXDocument:GetDOM("Expense GLs")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:GL[../d:Company = xdXDocument:get-DOM()/my:myFields/my:Company and ../d:Title =current()/../my:Expense_type]

    Hilary Stoupa

  • 09-08-2015 02:40 PM In reply to

    • mcharnell
    • Not Ranked
    • Joined on 08-01-2014
    • Vancouver, BC
    • Posts 15

    Re: Using current() to filter results to a specific table row (node)

     You are a genius!  Thank you so much.

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