default value

in dropdown i have to show default values then it has only single value if dropdown has multiple choices i can show then value will be null

ex:  here detail has many values this i have to show as it is no change in this 

 this dropdown has single option so need to show that by default 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    You can check the length of the options and then use them in the value parameter if its 1.

    Here's the code for your reference:

    a!localVariables(
      local!options: {"a"},
      local!selectedValue: if(
        length({local!options}) = 1,
        local!options,
        null
      ),
      {
        a!dropdownField(
          label: "dropdown",
          choiceLabels: local!options,
          choiceValues: local!options,
          placeholder: "--select a value--",
          value: local!selectedValue,
          saveInto: local!selectedValue
        )
      }
    )

    Let me know if you need any other support.

Reply
  • 0
    Certified Lead Developer

    You can check the length of the options and then use them in the value parameter if its 1.

    Here's the code for your reference:

    a!localVariables(
      local!options: {"a"},
      local!selectedValue: if(
        length({local!options}) = 1,
        local!options,
        null
      ),
      {
        a!dropdownField(
          label: "dropdown",
          choiceLabels: local!options,
          choiceValues: local!options,
          placeholder: "--select a value--",
          value: local!selectedValue,
          saveInto: local!selectedValue
        )
      }
    )

    Let me know if you need any other support.

Children
No Data