Question on using SAIL to pull information from DB

Hi

I am working on version 16.1.

I have a scenario where I want to display names of fruits in my drop down on SAIL whose values I am getting from DB.
In DB there are four distinct fruit names i.e. Apple, Orange, Banana, Mango and I am fetching these values via. query rule on my SAIL interface itself.
The SAIL interface rule is:
                                                                      load(
                                                                                 local!fruit,
                                                                                 local!dropDownValues:union(rule!Get_FruitData().fruitname,rule!Get_FruitData().fruitname),
                                                                                 a!formLayout(
                                                                                          label:"Drop Down Test",
                                                                                          firstColumnContents:{
                                                                                           a!dropdownField(
                                                                                                    label:"Fruit Names",
                                                                                                    placeholderLabel:"Select a fruit",
                                                                                                    choiceLabels:local!dropDownValues,
                                                                                                    choiceValues:local!dropDownValues,
                                                                                                    value:ri!fruit,
                                                                                                    saveInto:{ri!fruit
                                                                                                    }
                                                                                           )
                                                                                          },
                                                                                          buttons:a!buttonLayout(
                                                                                           primaryButtons:{
                                                                                                    a!buttonWidgetSubmit(
                                                  ...

OriginalPostID-211459

OriginalPostID-211459

  Discussion posts and replies are publicly visible

Parents
  • As you said, when the choice value gets removed/modified in the back end, existing instances having those values will create issue when rendering.

    You can do two things,

    1. When rendering the dropdown component you can simply ignore the previously selected value and force the user to select a new value again from the dropdown.

    a!dropdownField(
              label:"Fruit Names",
              placeholderLabel:"Select a fruit",
              choiceLabels:local!dropDownValues,
              choiceValues:local!dropDownValues,
              value: if(and(not(rule!APN_isBlank(local!fruit)), contains(local!dropDownValues, local!fruit)), local!fruit, null),
              saveInto:{
                        local!fruit,
                        a!save(ri!fruit,local!fruit)
              }
    )

    2. If you feel that will affect user experience (value getting disappeared suddenly), you can compute the same logic in a local variable and display a warning message to the user saying, the choice value was modified and is no longer available for selection
Reply
  • As you said, when the choice value gets removed/modified in the back end, existing instances having those values will create issue when rendering.

    You can do two things,

    1. When rendering the dropdown component you can simply ignore the previously selected value and force the user to select a new value again from the dropdown.

    a!dropdownField(
              label:"Fruit Names",
              placeholderLabel:"Select a fruit",
              choiceLabels:local!dropDownValues,
              choiceValues:local!dropDownValues,
              value: if(and(not(rule!APN_isBlank(local!fruit)), contains(local!dropDownValues, local!fruit)), local!fruit, null),
              saveInto:{
                        local!fruit,
                        a!save(ri!fruit,local!fruit)
              }
    )

    2. If you feel that will affect user experience (value getting disappeared suddenly), you can compute the same logic in a local variable and display a warning message to the user saying, the choice value was modified and is no longer available for selection
Children
No Data