Cascading drop down in a grid

Hi,

We have an issue with cascading drop downs within a grid. As there are two sets of drop downs which are dynamically updated within the grid. 

However where we have multiple rows, when one drop down is set to the place holder; the related drop down where we set the ri to null will throw the error below

Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!forEach [line 25]: Error in a!forEach() expression during iteration 3: Expression evaluation error at function a!dropdownField [line 71]: A dropdown component [label=“”] has an invalid value for “value”. All selected values must be present in the choiceValues array, but value was 11 and choiceValues was .

 


 

  Discussion posts and replies are publicly visible

Parents
  • a!dropdownField(
      required: true,
      placeholderLabel: "--- select document type ---",
      choiceLabels: local!docTypes.description,
      choiceValues: local!docTypes.commonCodeId,
      value: if(rule!PRO_TK_IsNull(ri!documentTypeIds), "", index(ri!documentTypeIds, fv!index, "")),
      saveInto: {
        if(
          rule!PRO_TK_IsNull(ri!documentSubtypeIds),
          {},
          a!save(ri!documentSubtypeIds, updatearray(ri!documentSubtypeIds, fv!index, ""))
        ),
        a!save(ri!documentTypeIds, updatearray(ri!documentTypeIds, fv!index, save!value))
      }
    ),
    a!dropdownField(
      required: true,
      placeholderLabel: "--- select document subtype ---",
      choiceLabels: if(or(rule!PRO_TK_IsNull(ri!documentTypeIds), length(ri!documentTypeIds)<fv!index, rule!PRO_TK_IsNull(ri!documentTypeIds[fv!index])), null, local!docSubtypes[wherecontains(ri!documentTypeIds[fv!index], index(local!docSubtypes,"parentId"))].description),
      choiceValues: if(or(rule!PRO_TK_IsNull(ri!documentTypeIds), length(ri!documentTypeIds)<fv!index, rule!PRO_TK_IsNull(ri!documentTypeIds[fv!index])), null, local!docSubtypes[wherecontains(ri!documentTypeIds[fv!index], index(local!docSubtypes,"parentId"))].commonCodeId),
      value: if(rule!PRO_TK_IsNull(ri!documentSubtypeIds), "", index(ri!documentSubtypeIds, fv!index, "")),
      saveInto: a!save(ri!documentSubtypeIds, updatearray(ri!documentSubtypeIds, fv!index, save!value)),
      disabled: rule!PRO_TK_IsNull(index(ri!documentTypeIds, fv!index, {}))
    )

     

    Here's the code snippet. The value being set is ri!documentSubtypeIds which is an array of intergers. The issue only arises when the array has three values and the second element is being set. The ri being set is definitely set correctly, however the drop down error persists 

  • +1
    Certified Lead Developer
    in reply to jansenn
    That's nice and complicated. For debug purposes, I suggest you temporarily comment out the dropdown field for the subtype and replace it with a text field showing you the current value of ri!documentSubtypeIds. From the error message you posted initially it's clear that the dropdown is attempting to show a value even after the choiceValues for that particular location have been emptied - and therefore I suspect either that your value parameter is picking up the wrong index somehow, or your saveInto isn't really correctly removing the value from the array when the first dropdown is changed.
  • Please try all the suggestions above, use text or paragraph so you can debug the content of the variables.

    From the initial error you posted and your code, It looks like you are using as value that is not in the choicesValues or the choicesValues is empty and you are trying to set a value.

    With that i think you can debug but If you need more help I would suggest to add the paragraph hide the second Dropdown (to avoid the error) and post here the content of the variables.

    Best Regards
    José Perez
Reply
  • Please try all the suggestions above, use text or paragraph so you can debug the content of the variables.

    From the initial error you posted and your code, It looks like you are using as value that is not in the choicesValues or the choicesValues is empty and you are trying to set a value.

    With that i think you can debug but If you need more help I would suggest to add the paragraph hide the second Dropdown (to avoid the error) and post here the content of the variables.

    Best Regards
    José Perez
Children
No Data