Set field in repeating table from other repeating table - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Set field in repeating table from other repeating table

Last post 03-21-2018 02:31 PM by Hilary Stoupa. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 03-15-2018 08:25 AM

    • joubin
    • Not Ranked
      Male
    • Joined on 03-13-2018
    • Poland
    • Posts 14

    Set field in repeating table from other repeating table

    In an offline form (not browser-enabled) I have a repeating table (Master) for vehicle license plates (field my:car) and fuel amount (my:car_liters).

    From another view, in second repeating table (Invoices) users select a vehicle from drop-down column (my:VehicleNo) and put the liters of fuel they filled on a given date (my:Liters).

    A button accepts the value and should update the fuel field of (my:car_liters) in the master table.

    I tried to set a filtered Action Rule to the button using the current() function as suggested by Hilary Stoupa in my xPath:

    <xsf:assignmentAction>targetField="../../my:group/my:car/@my:car_liters[../@my:car=current()/../my:VehicleNo]" expression="my:Liters"></xsf:assignmentAction>

    but it does not work.

    How can I assign current row's fuel value?

  • 03-16-2018 08:09 AM In reply to

    Re: Set field in repeating table from other repeating table

    Can I see your form? You can attach it under the Options tab in a reply.
    Hilary Stoupa

  • 03-19-2018 06:37 AM In reply to

    • joubin
    • Not Ranked
      Male
    • Joined on 03-13-2018
    • Poland
    • Posts 14

    Re: Set field in repeating table from other repeating table

     here we go...

    I managed to set the default value, but it only works for the very first item in table 'cars'. 

  • 03-19-2018 07:50 AM In reply to

    Re: Set field in repeating table from other repeating table

    So - you want to update this when the "OK" button is clicked?
    Hilary Stoupa

  • 03-19-2018 08:51 AM In reply to

    • joubin
    • Not Ranked
      Male
    • Joined on 03-13-2018
    • Poland
    • Posts 14

    Re: Set field in repeating table from other repeating table

    Hilary Stoupa:
    So - you want to update this when the "OK" button is clicked?
     

    exactly, so every time user fills up the car the value of liters shall increase. Seems to be tricky how to point to the car currently chosen from drop-down... 

  • 03-19-2018 09:07 AM In reply to

    Re: Set field in repeating table from other repeating table

    Will there be any starting data in the liters in the table on the settings page? Or will it always just be the total from the other table when the user fills up the car?
    Hilary Stoupa

  • 03-19-2018 10:25 AM In reply to

    • joubin
    • Not Ranked
      Male
    • Joined on 03-13-2018
    • Poland
    • Posts 14

    Re: Set field in repeating table from other repeating table

    Hilary Stoupa:
    Will there be any starting data in the liters in the table on the settings page? Or will it always just be the total from the other table when the user fills up the car?
     

    initially the liters will be empty, just gradually filling up for every invoice (i.e. to track gas usage per quarter) 

  • 03-19-2018 11:57 AM In reply to

    Re: Set field in repeating table from other repeating table

    I think a default value would do this then, but I'm confused by your nested repeating data. Can you help me understand why both the group and the field are repeating?
    Hilary Stoupa

  • 03-20-2018 05:02 AM In reply to

    • joubin
    • Not Ranked
      Male
    • Joined on 03-13-2018
    • Poland
    • Posts 14

    Re: Set field in repeating table from other repeating table

     I think this was a leftover of a previous design, but should not interfere with functionality.

    the default value does not work for consecutive cars unfortunately!

    I tried something in code behind, but it doesn't update the field properly:

    try

    {

    XPathNavigator myForm = MainDataSource.CreateNavigator();

    XPathNavigator field0 = myForm.SelectSingleNode("/my:myFields/my:Invoices_List/my:group6/my:VehicleNo", NamespaceManager);

    XPathNavigator field1 = myForm.SelectSingleNode("/my:myFields/my:Invoices_List/my:group6/my:Liters", NamespaceManager);

    XPathNavigator field2 = myForm.SelectSingleNode("/my:myFields/my:group10/my:group11/my:car1/@my:car1_liters", NamespaceManager);

    String P0 = field0.Value;

    String P1 = field1.Value;

    String P2 = field2.Value;

    MessageBox.Show(P0 + " " + P1 + " " + P2, "Warning", MessageBoxButtons.YesNo);

    field2.SetValue(P1);

    }

    catch (Exception ex)

  • 03-20-2018 08:09 AM In reply to

    Re: Set field in repeating table from other repeating table

    Here's your form using a calculated default.
    Hilary Stoupa

  • 03-21-2018 05:14 AM In reply to

    • joubin
    • Not Ranked
      Male
    • Joined on 03-13-2018
    • Poland
    • Posts 14

    Re: Set field in repeating table from other repeating table

     Hilary, you're a genius!!

    Amazingly simple how you used the .=current()/ function

    Thanks a lot 

  • 03-21-2018 02:31 PM In reply to

    Re: Set field in repeating table from other repeating table

    Glad that worked for you. The current() function is very useful - it always refers to the current context node, so if you had a rule on a button, for example, current() is the node the section the button is in is bound to. :)
    Hilary Stoupa

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