How to Retrieve Data

Hi Everyone,

I need to get "choiceLabels" and "choiceValues" list from the dictionary as shown in screenshot. Can anyone please help me how to get it?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    If i understood correctly, you need to retrieve choiceValue and choiceLabel from dictionary.

    Use index() for null safe expression
    local!choiceLabels: index(yourDictionary, "choiceLabels", {}),
    local!choiceValues: index(yourDictionary, "choiceValues", {}),

    Check below interface expression for your reference.

    a!localVariables(
      /* Example dictionary similar to yours */
      local!myDictionary: a!map(
        choiceValues: {"001", "002", "003", "004", "005"},
        choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4", "Option 5"},
        data: {/* your data here */}
      ),
    
      /* Extract both lists */
      local!extractedLabels: index(local!myDictionary, "choiceLabels", {}),
      local!extractedValues: index(local!myDictionary, "choiceValues", {}),
    
      /* Variable to store selected value */
      local!selectedValue: null,
    
      /* Display in a form */
      a!formLayout(
        titleBar: "Dictionary Example",
        contents: {
          /* Use in dropdown */
          a!dropdownField(
            label: "Select an Option",
            placeholder: "Choose...",
            choiceLabels: local!extractedLabels,
            choiceValues: local!extractedValues,
            value: local!selectedValue,
            saveInto: local!selectedValue
          ),
    
        }
      )
    )

Reply
  • 0
    Certified Lead Developer

    If i understood correctly, you need to retrieve choiceValue and choiceLabel from dictionary.

    Use index() for null safe expression
    local!choiceLabels: index(yourDictionary, "choiceLabels", {}),
    local!choiceValues: index(yourDictionary, "choiceValues", {}),

    Check below interface expression for your reference.

    a!localVariables(
      /* Example dictionary similar to yours */
      local!myDictionary: a!map(
        choiceValues: {"001", "002", "003", "004", "005"},
        choiceLabels: {"Option 1", "Option 2", "Option 3", "Option 4", "Option 5"},
        data: {/* your data here */}
      ),
    
      /* Extract both lists */
      local!extractedLabels: index(local!myDictionary, "choiceLabels", {}),
      local!extractedValues: index(local!myDictionary, "choiceValues", {}),
    
      /* Variable to store selected value */
      local!selectedValue: null,
    
      /* Display in a form */
      a!formLayout(
        titleBar: "Dictionary Example",
        contents: {
          /* Use in dropdown */
          a!dropdownField(
            label: "Select an Option",
            placeholder: "Choose...",
            choiceLabels: local!extractedLabels,
            choiceValues: local!extractedValues,
            value: local!selectedValue,
            saveInto: local!selectedValue
          ),
    
        }
      )
    )

Children
No Data