Navigate through the fields in a repeating table - InfoPath Dev
in

InfoPath Dev

Navigate through the fields in a repeating table

Last post 12-13-2010 07:30 AM by Patrick Halstead. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 12-06-2010 06:30 AM

    • josera
    • Not Ranked
      Male
    • Joined on 07-28-2010
    • Sacheon (South Korea)
    • Posts 9

    Navigate through the fields in a repeating table

    Hi,

    In one field of a repeating table, the user selects a date with a date picker. With the date I calculate the week of the year and I write it in other field of the same line of the repeating table. I am using VBScript. @Day is the date picker and @WeekOfTheYear is the destination field. I get to @Day attribute node with eventObj.Site so I calculate the week of the year like this:

    DIM weekOfYear

    weekOfYear = DatePart("ww", eventObj.Site.text, 2, 3)

    Now I should write the calculated value in the destination but I cannot find the way to navigate from @Day to @WeekOfTheYear (both in the same line of the repeating table), using XPathNavigator. In fact, It would be very simple to do if the calculations could be done with the Infopath available functions. In that case it could be done without code. I have done it for other calculations. But in this case I need to use VBScript and then the navigation from one attribute node to another sibling attribute node shows up.

    It looks to me that the solution should be very simple but nothing that I tried works. I would appreciate any help.

    Josera

  • 12-13-2010 04:56 AM In reply to

    Re: Navigate through the fields in a repeating table

    Hi Josera,

    First of all, it seems you are using attributes and not fields. Why is that? Why not use fields instead? Might make it easier to reference.

    To calculate Week of the Year, you should be able to do this with xpath: just subtract out the value for the beginning of the year and divide by seven. If the value is greater than 52, you can have another rule and function that subtracts 52. You will need to hardcode the value for the beginning of the year - just create a sample form with a datepicker and use it to identify the value. No code should be required.

    Maybe I am confused though ....

    Patrick Halstead
    Project Manager at Qdabra
  • 12-13-2010 05:50 AM In reply to

    • josera
    • Not Ranked
      Male
    • Joined on 07-28-2010
    • Sacheon (South Korea)
    • Posts 9

    Re: Navigate through the fields in a repeating table

    Thanks Patrick for your contribution.

     My form is based on SQL Server and Infopath forces me to use the data structure that it generates. This data structure is built on attributes so I don't have a choice.

    This is just a particular case. What I wanted to know is the way to navigate through the same line in a repeating table. I continued reading and experimenting and finally I made it work. This is the code that does it:

    it is triggered after I select a date in the date picker of the column @Day in the repeating table, and after calculating the week of the year, it writes it on the column @WeekOfYear of the same line.

    SUB msoxd__ItemLines_Day_attr_OnAfterChange(eventObj)

    DIM fWeekOfYear

    DIM day

    day = eventObj.Site.text

    SET fWeekOfYear = eventObj.Site.selectSingleNode("../@WeekOfYear")    ' This is the key to navigate to another column in the same line

    fWeekOfYear.text = DatePart("ww", day, vbMonday, vbFirstFullWeek)          ' Calculation of the week of the year and writing it in other column

    END SUB

    Josera

  • 12-13-2010 07:30 AM In reply to

    Re: Navigate through the fields in a repeating table

    Great to hear you figured it out!

    And, *THANKS* for posting your intelligence so that others can benefit. :)

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