Skip to main content
April 23, 2022
Question

Dropdown with an array

  • April 23, 2022
  • 4 replies
  • 0 views

Hi,

When I am trying to assign an array to a local variable and use the same for dropdown choiceLabels and choiceValues, I am getting an error.

Any idea why I am getting this error. 

    4 replies

    Inspiring
    April 23, 2022

    Hi,

    Don't use merge function to append two arrays. Review Appian documentation if you are not sure about that function. I am posting a sample code here, it will work for your case.

    a!localVariables(
      local!reviewOptionLable1AI: {"Additional Info Required"},
      local!reviewOptionValueAI: {"AIR"},
      local!reviewOptionLabelCancel: {"Cancelled"},
      local!reviewOptionValueCancel: {"CSED"},
      local!reviewOptionLable: {local!reviewOptionLable1AI, local!reviewOptionLabelCancel},
      local!reviewOptionValue: {local!reviewOptionValueAI, local!reviewOptionValueCancel},
      a!formLayout(
        contents: {
          a!dropdownField(
            label: "Review Options",
            placeholder: "--- Select a Review Option ---",
            choiceLabels: local!reviewOptionLable,
            choiceValues: local!reviewOptionValue,
            value: "",/*your rule input*/
            saveInto: {
              /*save back to your rule input*/
            }
          )
        }
      )
    )
     

    April 23, 2022

    Thanks

    harshitb6843
    April 23, 2022

    Use the append or flatten function instead. 
    Flatten is used to flat a nested array. Append, as the name suggests, is used to append a variable to an array. Using merge will create a nested array that will cause problems. 

    April 23, 2022

    Thanks