Choice values and choice label

Hi,

i have two dropdown field, when i select one some values related to that dropdown will be selected in next dropdown.. but after selecting values in both the dropdown when i try to change the value in first dropdown it throwing the error.. actually it has to erase the value in second dropdown and show the values to select 

below i have attached the code and the UI

this is the UI for ex: when i select stand-by lc and related detail i have to select after selecting the detail if i try to change the collateral type then it is giving error 

when i try to change the collateral type then detail data need to erase how can i achieve this  

 a!dropdownField(
                /*label:"Collateral Type"*/
                placeholderLabel: cons!CR_APP_TXT_PLACEHOLDER_VALUE,
                choiceLabels: touniformstring(
                  rule!APN_distinct(
                    index(
                      ri!crREFCollateral_cdt,
                      "collateralDescription_txt",
                      {}
                    )
                  )
                ),
                choiceValues: touniformstring(
                  rule!APN_distinct(
                    index(
                      ri!crREFCollateral_cdt,
                      "collateralCode_int",
                      {}
                    )
                  )
                ),
                value: tostring(
                  index(
                    fv!item,
                    "collateralCode_int",
                    {}
                  )
                )
              ),
              a!dropdownField(
                /*label:"Detail"*/
                placeholderLabel: cons!CR_APP_TXT_PLACEHOLDER_VALUE,
                choiceLabels: index(
                  ri!crREFCollateral_cdt,
                  wherecontains(
                    fv!item.collateralCode_int,
                    ri!crREFCollateral_cdt.collateralCode_int
                  ),
                  {}
                ).collateralTypeDescription_txt,
                choiceValues: touniformstring(
                  index(
                    ri!crREFCollateral_cdt,
                    wherecontains(
                      tostring(
                        fv!item.collateralCode_int
                      ),
                      touniformstring(
                        ri!crREFCollateral_cdt.collateralCode_int
                      )
                    ),
                    {}
                  ).collateralTypeCode_int
                ),
                value: tostring(
                  fv!item.collateralTypeCode_int
                )
              )
             

  Discussion posts and replies are publicly visible

  • +1
    Certified Senior Developer

    HI , To make this working, you would need to make sure you are making second dropdown value null whenever first dropdown's value changes. So in first doropdown's saveInto parameter , just make that value null.it should fix your problem then.

  • 0
    Certified Lead Developer

    You'd need to show us the saveInto parameters of both dropdowns, particularly the first one as per what Gopalk already said, the first one will need to manually save a blank value into the value being used by the second one, to prevent its value from becoming an invalid selection when the value in the first one is changed.

    Also: I would strongly recommend against using "distinct" funcitons separately on the "choiceLabels" and "choiceValues" arrays like you're currently doing in the top dropdown - because you will very quickly find yourself in a situation where the dropdown breaks when one of those arrays contains a duplicate and the other one doesn't, thus causing both lists to be different lengths, which will break the dropdown field.

    I would replace these with simply this:

    choiceLabels: property( ri!crREFCollateral_cdt, "collateralDescription_txt", {} ),
    choiceValues: property( ri!crREFCollateral_cdt, "collateralCode_int", {} ),

    If you're worried that ri!crREFCollateral_cdt will contain duplicate entries, you should do the de-duplication on the CDT array as a whole, either at query time or right afterwards (like in a subsequent local variable).  I also removed the toUniformString calls as they are almost never necessary in this context.

  • Hi   i have included mentioned code in saveInto instead of value parameter 

     fv!item.collateralCode_int,
                      a!save(
                        fv!item.collateralTypeCode_int,
                        null
                      ),