Iterating over links in an array of maps doesn't work consistently

Certified Associate Developer

I have an array of maps that I iterate over and generate cards with links like so:

local!selectedCard,
local!example:
    {a!map(
          icon: "first-aid",
          name: "name1",
          link: a!dynamicLink(saveInto: a!save(local!selectedCard, 1))
        ),
    a!map(
        icon: "home",
        name: "name2",
        link: a!startProcessLink(
          processModel: some process,
          processParameters: {
            /* some params */
          }
        )
      ),
      /* some more options */
      },
      {
      
      a!columnsLayout(
          columns: {
            a!columnLayout(),
            a!forEach(
              items: local!options,
              expression: a!columnLayout(
                contents: {
                  a!cardLayout(
                    contents: {
                      a!richTextDisplayField(
                        labelPosition: "COLLAPSED",
                        value: {
                          char(10),
                          char(10),
                          a!richTextIcon(
                            icon: fv!item.icon,
                            color: "SECONDARY",
                            size: "MEDIUM_PLUS"
                          ),
                          char(10),
                          char(10),
                          a!richTextItem(
                            text: fv!item.name,
                            color: "SECONDARY",
                            size: "MEDIUM",
                            style: "STRONG"
                          )
                        },
                        align: "CENTER"
                      )
                    },
                    link: fv!item.link,
                    height: "SHORT_PLUS",
                    shape: "ROUNDED"
                  )
                },
                width: "MEDIUM"
              )
            ),
            a!columnLayout()
          },
          showWhen: a!isNullOrEmpty(local!selectedCard),
          marginBelow: "STANDARD"
        )
      
      }


This doesn't work. When I click on the appropriate card, the variable local!selectedCard is still null even though I specified it should be set to 1. When I click on the process model card however that works fine. The dynamic link property of the map entry has all it's fields set to null after evaluation. Why is that so? If I use this code instead of fv!item.link for the link parameter of the card the code works:

/* card link param */
link: if(
          fv!index = 2,
          a!startProcessLink(
            processModel: some_process_model,
            processParameters: {
              /* some params */
            }
          ),
          a!dynamicLink(saveInto: a!save(local!selectedCard, fv!index))
        )

However this way it is obvious if I (or someone else) in the future add an entry to the array the index specified might be wrong and the whole thing will break.

  Discussion posts and replies are publicly visible