Defining a list of chart series in a local variable with links

I have noticed that if I have a bar chart with the series parameter being defined earlier inside a local variable, even if the local variable has dynamic links configured, they don't work.

However, if I just put the definition of the series into the bar chart component directly without changing the definition of the dynamic links, they work perfectly. 

Why is there a difference between these two implementations? 


In the following implementation, clicking the bar chart does not save the message

a!localVariables(
  local!message,
  local!series: a!chartSeries(
    label: "label",
    data: 5,
    links: a!dynamicLink(
      saveInto: a!save(local!message, "Saved")
    )
  ),
  {
    a!gridField(
      local!message
    ),
    a!barChartField(
      categories: "Category",
      series: local!series
    )
  }
)




In this code below, it now does. 

a!localVariables(
  local!message,
  {
    a!gridField(
      local!message
    ),
    a!barChartField(
      categories: "Category",
      series: a!chartSeries(
        label: "label",
        data: 5,
        links: a!dynamicLink(
          saveInto: a!save(local!message, "Saved")
        )
      )
    )
  }
)

  Discussion posts and replies are publicly visible

Parents
  • I believe this issue happens due to how you are using a!localVariables. The default behavior of any local variables is to only allow saving / updates based on the change of a referenced variable. However, local!message only changes because of saving into local!series, so the save never ends up happening.

    If you change the variables to use a!refreshVariable(), then this behavior should work:

    a!localVariables(
      local!message,
      local!series: a!refreshVariable(
        value: a!chartSeries(
          label: "label",
          data: 5,
          links: a!dynamicLink(
            saveInto: a!save(local!message, "Saved")
          )
        ),
        refreshAlways: true,
      ),
      {
        a!gridField(
          local!message
        ),
        a!barChartField(
          categories: "Category",
          series: local!series
        )
      }
    )

Reply
  • I believe this issue happens due to how you are using a!localVariables. The default behavior of any local variables is to only allow saving / updates based on the change of a referenced variable. However, local!message only changes because of saving into local!series, so the save never ends up happening.

    If you change the variables to use a!refreshVariable(), then this behavior should work:

    a!localVariables(
      local!message,
      local!series: a!refreshVariable(
        value: a!chartSeries(
          label: "label",
          data: 5,
          links: a!dynamicLink(
            saveInto: a!save(local!message, "Saved")
          )
        ),
        refreshAlways: true,
      ),
      {
        a!gridField(
          local!message
        ),
        a!barChartField(
          categories: "Category",
          series: local!series
        )
      }
    )

Children