How to save a Array into a Local Variable/RI at a Specific Index?

The idea that I want to do is be able to save a specific answer into a specific spot into an array. I want to be able to select multiple drop downs save it into one array and then put that in the CDT to be referenced. I do not want to use a multiple dropdown because thats not in the scope of what I have to do nor is it plausible for the problem I have to complete. 

The basis of this interface is supposed to be able to click the add button add another option and then select if its the primary or not and then save those. 

This code you can play around with yourself: 

a!localVariables(
  local!pubProd: {null},
  local!dataProd1: {null},
  local!count: 1,
  local!datacount: 1,
  {
    a!cardLayout(
      contents: {
        a!forEach(
          items: enumerate(local!count),
          expression: 
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!dropdownField(
                    label: "Producing Organization",
                    labelPosition: "ABOVE",
                    placeholder: "--- Select a Value ---",
                    choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4",
                    "Option 5", "Option 6", "Option 7", "Option 8",
                    "Option 9", "Option 10", "Option 11", "Option 12"},
                    choiceValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
                    value: local!pubProd[fv!index], 
                    saveInto: {local!pubProd[fv!index]},
                    searchDisplay: "AUTO",
                    validations: {}
                  )
                },
              ),
              a!columnLayout(
                contents: {
                  a!checkboxField(
                    label: "Primary",
                    labelPosition: "ABOVE",
                    choiceLabels: {""},
                    choiceValues: {true},
                    saveInto: {},
                    choiceLayout: "COMPACT",
                    choiceStyle: "STANDARD",
                    validations: {},
                    align: "CENTER"
                  )
                },
                width: "EXTRA_NARROW" 
              )
            }
          )
        ),
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!buttonArrayLayout(
                  buttons: {
                    a!buttonWidget(
                      label: "Remove",
                      icon: "minus",
                      value: local!count - 1,
                      saveInto: local!count,
                      size: "SMALL",
                      style: "LINK"
                    )
                  },
                  align: "END"
                )
              },
              width: "AUTO"
            ),
            a!columnLayout(
              contents: {
                a!buttonArrayLayout(
                  buttons: {
                    a!buttonWidget(
                      label: "Add",
                      icon: "plus",
                      value: local!count + 1,
                      saveInto: local!count,
                      size: "SMALL",
                      width: "MINIMIZE",
                      style: "LINK"
                    )
                  },
                  align: "END",
                  marginBelow: "STANDARD"
                )
              },
              width: "EXTRA_NARROW"
            )
          }
        ),
      },
      height: "AUTO",
      style: "NONE",
      marginBelow: "STANDARD"
    ),

    a!cardLayout(
      contents: {
        a!forEach(
          items: enumerate(local!datacount),
          expression: 
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!dropdownField(
                    label: "Data Producing Organization",
                    labelPosition: "ABOVE",
                    placeholder: "--- Select a Value ---",
                    choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4",
                    "Option 5", "Option 6", "Option 7", "Option 8",
                    "Option 9", "Option 10", "Option 11", "Option 12"},
                    choiceValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
                    value: local!dataProd1[fv!index],
                    saveInto: {local!dataProd1[fv!index]},
                    searchDisplay: "AUTO",
                    validations: {}
                  ),
                }
              ),
              a!columnLayout(
                contents: {
                  a!checkboxField(
                    label: "Primary",
                    labelPosition: "ABOVE",
                    choiceLabels: {""},
                    choiceValues: {true},
                    saveInto: {},
                    choiceLayout: "COMPACT",
                    choiceStyle: "STANDARD",
                    validations: {},
                    align: "CENTER"
                  )
                },
                width: "EXTRA_NARROW" 
              )
            }
          )
        ),
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!buttonArrayLayout(
                  buttons: {
                    a!buttonWidget(
                      label: "Remove",
                      icon: "minus",
                      value: local!datacount - 1,
                      saveInto: local!datacount,
                      size: "SMALL",
                      style: "LINK"
                    )
                  },
                  align: "END"
                )
              },
              width: "AUTO"
            ),
            a!columnLayout(
              contents: {
                a!buttonArrayLayout(
                  buttons: {
                    a!buttonWidget(
                      label: "Add",
                      icon: "plus",
                      value: local!datacount + 1,
                      saveInto: local!datacount,
                      size: "SMALL",
                      width: "MINIMIZE",
                      style: "LINK"
                    )
                  },
                  align: "END",
                  marginBelow: "STANDARD"
                )
              },
              width: "EXTRA_NARROW"
            )
          }
        )
      },
      height: "AUTO",
      style: "NONE",
      marginBelow: "STANDARD"
    ),
  }
)

  Discussion posts and replies are publicly visible

Parents Reply
  • +1
    A Score Level 1
    in reply to Kyle G

    The type of the choice values & the Value is different

    typename(typeof(local!pubProd[1])) --> using this you can confirm the data types is different(use this for future findings)

    the choice values - integer type  (but)

    local!dataProd1[fv!index] is returning text type 

    So cast() both choice values and the value as same datatype or in simple you can try this        tointeger(local!dataProd1[fv!index])

Children