How to define a local variable to be a list?

I defined local!valuelist from a!localVariables, however, it is not a list so i can't saveinto form such as local!valuelist.username,local!valuelist.password, how can i transfer the format of this local value?

  Discussion posts and replies are publicly visible

Parents
  • I'm not entirely sure what you're trying to do but see this code for a local variable that is a list. If this doesn't help then you'll need to give more specific information.

    Note that I've used two different ways of referencing where I want things saved. They function exactly the same.

    1. Quoted square brackets indexing (eg. local!valueList[fv!index]["username"])
    2. Dot notation (eg. local!valueList[fv!index].password)

    a!localVariables(
      local!valueList,
      {
        a!forEach(
          items: local!valueList,
          expression: a!sideBySideLayout(
            items: {
              a!sideBySideItem(
                item: a!textField(
                  label: concat(
                    "Username ",
                    fv!index
                  ),
                  labelPosition: "ADJACENT",
                  value: index(
                    fv!item,
                    "username",
                    {}
                  ),
                  saveInto: local!valueList[fv!index]["username"]
                )
              ),
              a!sideBySideItem(
                item: a!textField(
                  label: concat(
                    "Password ",
                    fv!index
                  ),
                  labelPosition: "ADJACENT",
                  value: index(
                    fv!item,
                    "password",
                    {}
                  ),
                  saveInto: local!valueList[fv!index].password
                )
              ),
              a!sideBySideItem(
                item: a!richTextDisplayField(
                  label: concat(
                    "Delete row ",
                    fv!index
                  ),
                  labelPosition: "COLLAPSED",
                  value: a!richTextIcon(
                    icon: "times",
                    color: "NEGATIVE",
                    link: a!dynamicLink(
                      value: remove(
                        local!valueList,
                        fv!index
                      ),
                      saveInto: local!valueList
                    )
                  )
                )
              )
            }
          )
        ),
        a!richTextDisplayField(
          label: "Add new entry to list",
          labelPosition: "COLLAPSED",
          value: {
            a!richTextIcon(
              icon: "plus-circle",
              link: a!dynamicLink(
                value: {
                  username: loggedInUser(),
                  password: "password123"
                }
              )
            ),
            a!richTextItem(
              text: "  Add new item to list",
              link: a!dynamicLink(
                value: append(
                  local!valueList,
                  {
                    username: loggedInUser(),
                    password: "password123"
                  }
                ),
                saveInto: local!valueList
              )
            )
          }
        )
      }
    )

    You could also explore the a!map() function rather than creating a dictionary such as what I did in the "+ Add new item to list" saves (starting at lines 68 and 79)

Reply
  • I'm not entirely sure what you're trying to do but see this code for a local variable that is a list. If this doesn't help then you'll need to give more specific information.

    Note that I've used two different ways of referencing where I want things saved. They function exactly the same.

    1. Quoted square brackets indexing (eg. local!valueList[fv!index]["username"])
    2. Dot notation (eg. local!valueList[fv!index].password)

    a!localVariables(
      local!valueList,
      {
        a!forEach(
          items: local!valueList,
          expression: a!sideBySideLayout(
            items: {
              a!sideBySideItem(
                item: a!textField(
                  label: concat(
                    "Username ",
                    fv!index
                  ),
                  labelPosition: "ADJACENT",
                  value: index(
                    fv!item,
                    "username",
                    {}
                  ),
                  saveInto: local!valueList[fv!index]["username"]
                )
              ),
              a!sideBySideItem(
                item: a!textField(
                  label: concat(
                    "Password ",
                    fv!index
                  ),
                  labelPosition: "ADJACENT",
                  value: index(
                    fv!item,
                    "password",
                    {}
                  ),
                  saveInto: local!valueList[fv!index].password
                )
              ),
              a!sideBySideItem(
                item: a!richTextDisplayField(
                  label: concat(
                    "Delete row ",
                    fv!index
                  ),
                  labelPosition: "COLLAPSED",
                  value: a!richTextIcon(
                    icon: "times",
                    color: "NEGATIVE",
                    link: a!dynamicLink(
                      value: remove(
                        local!valueList,
                        fv!index
                      ),
                      saveInto: local!valueList
                    )
                  )
                )
              )
            }
          )
        ),
        a!richTextDisplayField(
          label: "Add new entry to list",
          labelPosition: "COLLAPSED",
          value: {
            a!richTextIcon(
              icon: "plus-circle",
              link: a!dynamicLink(
                value: {
                  username: loggedInUser(),
                  password: "password123"
                }
              )
            ),
            a!richTextItem(
              text: "  Add new item to list",
              link: a!dynamicLink(
                value: append(
                  local!valueList,
                  {
                    username: loggedInUser(),
                    password: "password123"
                  }
                ),
                saveInto: local!valueList
              )
            )
          }
        )
      }
    )

    You could also explore the a!map() function rather than creating a dictionary such as what I did in the "+ Add new item to list" saves (starting at lines 68 and 79)

Children
No Data