Values not updating

Hi, 

I'm trying to create a basic interface, but I'm having some problems with the variables not updating as I expect them to.

Here is a code snippet:

 

load(
    local!date: today(),
    local!dateRange: rule!getWeekDateArray(local!date),
    a!formLayout(
        contents: {
            a!boxLayout(
                contents: {
                    with(
                        {
                            a!dateField(
                                label: "Date picker",
                                value: local!date,
                                saveInto: {
                                    local!date,
                                    a!save(target: local!dateRange, value: rule!getWeekDateArray(local!date))
                                }
                            ),
                            a!paragraphField(
                                label: "Dates",
                                value: local!dateRange
                            )
                        }
                    )
                }
            )
        }
    )
)

Once the user selects a date, the paragraph field should update with a list/array of values that represent the days of the month for a given week. For example, suppose the user selects the 17th of January 2019, the values listed will be "13; 14; 15; 16; 17; 18; 19" because these correspond with the days of the week for the selected date.

I have an expression rule that takes a date and returns this list (rule!getWeekDateArray()). I've tested the expression rule and it works as expected. For some reason, when the user changes the date, the array (and paragraph field) is only updated once. After that, it doesn't update any more - changes to the date picker have no effect. I have a feeling it has something to do with the way I declare/use local variables inside with() or load() but I can't figure it out. 

Here is my getWeekDateArray() expression rule:

 

load
(local!dateRange: choose(
  weekday(
    ri!date
  ),
  /* 1 */
  {
    left(ri!date, 2),
    left(ri!date + 1, 2),
    left(ri!date + 2, 2),
    left(ri!date + 3, 2),
    left(ri!date + 4, 2),
    left(ri!date + 5, 2),
    left(ri!date + 6, 2)
  },
  /* 2 */
  {
    left(ri!date - 1, 2),
    left(ri!date, 2),
    left(ri!date + 1, 2),
    left(ri!date + 2, 2),
    left(ri!date + 3, 2),
    left(ri!date + 4, 2),
    left(ri!date + 5, 2)
  },
  /* 3 */
  {
    left(ri!date - 2, 2),
    left(ri!date - 1, 2),
    left(ri!date, 2),
    left(ri!date + 1, 2),
    left(ri!date + 2, 2),
    left(ri!date + 3, 2),
    left(ri!date + 4, 2)
  },
  /* 4 */
  {
    left(ri!date - 3, 2),
    left(ri!date - 2, 2),
    left(ri!date - 1, 2),
    left(ri!date, 2),
    left(ri!date + 1, 2),
    left(ri!date + 2, 2),
    left(ri!date + 3, 2)
  },
  /* 5 */
  {
    left(ri!date - 4, 2),
    left(ri!date - 3, 2),
    left(ri!date - 2, 2),
    left(ri!date - 1, 2),
    left(ri!date, 2),
    left(ri!date + 1, 2),
    left(ri!date + 2, 2)
  },
  /* 6 */
  {
    left(ri!date - 5, 2),
    left(ri!date - 4, 2),
    left(ri!date - 3, 2),
    left(ri!date - 2, 2),
    left(ri!date - 1, 2),
    left(ri!date, 2),
    left(ri!date + 1, 2)
  },
  /* 7 */
  {
    left(ri!date - 6, 2),
    left(ri!date - 5, 2),
    left(ri!date - 4, 2),
    left(ri!date - 3, 2),
    left(ri!date - 2, 2),
    left(ri!date - 1, 2),
    left(ri!date, 2)
  }
),
local!dateRange
)

Any help on this would be great!

Regards, 

Ben

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data