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

  • 0
    Certified Lead Developer
    , Can you please post your code snippet here?
  • Code snippet can help to pinpoint the issues. But for now please check how you are setting the null value for ri.
  • 0
    Certified Lead Developer
    It sounds like the dropdown causing the error is having its choices removed (via 'cascading' i assume), but not having its value cleared first. You will need to manually correct for this in one of a few possible ways.
  • Thanks Mike, that's exactly the problem which I'm having. However setting the value to null or "" doesn't seem to fix this.
    What were the ways you mentioned?
  • 0
    Certified Lead Developer
    in reply to jansenn
    Have you double-checked that you're setting the value of the correct variable to null? Also, have you double-checked that the dropdown field in question has a placeholder defined, as the error would also happen if there's no placeholder?

    Various possibilities include:
    1) setting the value of the variable in question to null() in your saveInto
    2) simply not showing the dropdown field in question when the value of the next-higher-up dropdown is not set
    3) probably some others that i'm not thinking of at the moment and/or depend on the exact scenario

    As the earlier comments mentioned, we can help you a lot better if you provide the code section you're working with - otherwise there's no real way to help check for errors etc.
  • 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 

  • Thanks Mike. Just as you and Ramanjaneyulut suggested, I've included the code snippet. Just as you were replying :-)
    I've tried solution 1 and that's how it was setup originally. My colleague has tried solution 2 and it has the same issue. I'm going to try a variation of 2 and see how I go
  • +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
  • Thanks Mike, that a big help. I think the issue was that the value was being written to the incorrect index. I'll have to debug and investigate further.
    Exposing the current value of ri!documentSubtypeIds show this.
    ^_^; Yes I'm trying hard to move away from complicated design