Dropdown is not showing a preselected value from api response and throws an error, despite of the preselected value to show is in the dropdown list.

Three questions in the following scenario:

Scenario: Trying to show a preselected value from api response into Dropdown. The dropdown list is below. The value from Api response is "New" which is one of the option in the list. Still getting the below error. Using External Web Api to save updated Status value back into external DB.

Question 1: How to get rid of this error and show preselected value? This is a form layout with just one field editable to update status of a record and have used "DrillDown" template.

Format of the list shown in dropdown collected from expression view is: 

List of Dictionary: 3 items Dictionary Id: 1 Status: "New" Dictionary Id: 2 Status: "Confirmed" Dictionary Id: 3 Status: "Pending"

Dropdown Code: Question 2Please confirm if the below way of saving updated value into a rule input is correct? Question 3 And also advise how to refresh the screen to load latest values after updating the Status?

a!dropdownField(
label: "Status",
labelPosition: "ABOVE",
placeholderLabel: "--- Select a Value ---",
choiceLabels: index(
rule!GetStatusListNames_ExpRule(),
"Status",
{}
),
choiceValues: index(
rule!GetStatusListNames_ExpRule(),
"Status",
{}
),
value: local!selectedEvent.Status,
saveInto: a!save(
ri!Event.Status,
save!value
)
)

 

Error

Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!dropdownField [line 153]: A dropdown component [label=“Status”] has an invalid value for “value”. All selected values must be present in the choiceValues array, but value was New and choiceValues was New; Confirmed; Pending.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi,

    Can you try the below:

     

    with(
      local!choiceValuesTemp:  index(
          rule!GetStatusListNames_ExpRule(),
          "Status",
          {}
        ),
    /* below code will convert the value into list of string incase if the data returned by the above code is a string with semi-colon(;) separated */    
      local!choiceValues: if(rule!checkIsNullOrEmpty(local!choiceValuesTemp), {}, trim(touniformstring(split(local!choiceValuesTemp, ";")))),
      a!dropdownField(
        label: "Status",
        labelPosition: "ABOVE",
        placeholderLabel: "--- Select a Value ---",
        choiceLabels:local!choiceValues,
        choiceValues: local!choiceValues,
        value: if(contains(local!choiceValues, tostring(local!selectedEvent.Status)), tostring(local!selectedEvent.Status), null),
        saveInto: {
            a!save(
              ri!Event.Status,
              save!value
            ),
             a!save(
             local!selectedEvent.Status,
              save!value
            )
        }
      )
    )

Reply
  • 0
    Certified Lead Developer

    Hi,

    Can you try the below:

     

    with(
      local!choiceValuesTemp:  index(
          rule!GetStatusListNames_ExpRule(),
          "Status",
          {}
        ),
    /* below code will convert the value into list of string incase if the data returned by the above code is a string with semi-colon(;) separated */    
      local!choiceValues: if(rule!checkIsNullOrEmpty(local!choiceValuesTemp), {}, trim(touniformstring(split(local!choiceValuesTemp, ";")))),
      a!dropdownField(
        label: "Status",
        labelPosition: "ABOVE",
        placeholderLabel: "--- Select a Value ---",
        choiceLabels:local!choiceValues,
        choiceValues: local!choiceValues,
        value: if(contains(local!choiceValues, tostring(local!selectedEvent.Status)), tostring(local!selectedEvent.Status), null),
        saveInto: {
            a!save(
              ri!Event.Status,
              save!value
            ),
             a!save(
             local!selectedEvent.Status,
              save!value
            )
        }
      )
    )

Children
No Data