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
  • Update:

    If I predefine it like this:

      local!pubProd: repeat(4, null),
      local!dataProd1: repeat(4, null),

    it works well except for the error I get which is:

    Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 9]: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!dropdownField [line 16]: A dropdown component [label="Producing Organization"] has an invalid value for "value". All selected values must be present in the choiceValues array, but value was 1 and choiceValues was 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12.

Children