cascading Mutiple DropDown Dependancy

We have a use case where we need to display values in multiple drop down(say a) based on the previous multiple drop down (say b) values, there is no constrain as to which drop down should selected first. 

user can select any drop down and the other drop down should display value based on it. but when multiple values are selected, for each value the save into is executed and the drop down variables are refreshed and it is throwing an error.

It is either picking up only the first value and nullifying all the others , or it is nullfying the entire choice values. 

Interface Definition: Expression evaluation error at function a!multipleDropdownField [line 219]: A multiple dropdown component [label=“”] has an invalid value for “choiceValues”. Choice values cannot be null.

Please suggest as to what can be done to find out when all the values are saved into the variable in multiple dropdown

P.S we do not have buttons so all values should be calculated based on save into if dropdown alone

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    I think there is a problem with the logic used in the save into of the multiple drop-downs. Also I have created a sample code 

    load(
      local!dropdownOneLabels: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
      local!dropdownTwoLabels: {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"},
      local!dropdownOneValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
      local!dropdownTwoValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
      local!tmpDropdownOneLabels,
      local!tmpDropdownTwoLabels,
      local!tmpDropdownOneValues,
      local!tmpDropdownTwoValues,
      local!dropdownOne,
      local!dropdownTwo,
      with(
        {
          a!multipleDropdownField(
            label: "Dropdown One",
            labelPosition: "ABOVE",
            placeholder: "-- Select values in Dropdown One --",
            choiceLabels: if(and(rule!APN_isEmpty(local!dropdownTwo), rule!APN_isEmpty(local!tmpDropdownOneLabels)),
              local!dropdownOneLabels,
              local!tmpDropdownOneLabels
            ),
            choiceValues: if(and(rule!APN_isEmpty(local!dropdownTwo), rule!APN_isEmpty(local!tmpDropdownOneValues)),
              local!dropdownOneValues,
              local!tmpDropdownOneValues
            ),
            value: local!dropdownOne,
            saveInto: {
              local!dropdownOne,
              a!save(
                local!dropdownTwo,
                {}
              ),
              a!save(
                local!tmpDropdownTwoLabels,
                index(
                  local!dropdowntwoLabels,
                  local!dropdownOne,
                  {}
                )
              ),
              a!save(
                local!tmpDropdownTwoValues,
                index(
                  local!dropdownTwoValues,
                  local!dropdownOne,
                  {}
                )
              )
            }
          ),
          a!multipleDropdownField(
            label: "Dropdown Two",
            labelPosition: "ABOVE",
            placeholder: "-- Select values in Dropdown Two --",
            choiceLabels: if(and(rule!APN_isEmpty(local!dropdownOne), rule!APN_isEmpty(local!tmpDropdownTwoLabels)),
              local!dropdownTwoLabels,
              local!tmpDropdownTwoLabels
            ),
            choiceValues: if(and(rule!APN_isEmpty(local!dropdownOne), rule!APN_isEmpty(local!tmpDropdownTwoValues)),
              local!dropdownTwoValues,
              local!tmpDropdownTwoValues
            ),
            value: local!dropdownTwo,
            saveInto: {
              local!dropdownTwo,
              a!save(
                local!dropdownOne,
                {}
              ),
              a!save(
                local!tmpDropdownOneLabels,
                index(
                  local!dropdownOneLabels,
                  local!dropdownTwo,
                  {}
                )
              ),
              a!save(
                local!tmpDropdownOneValues,
                index(
                  local!dropdownOneValues,
                  local!dropdownTwo,
                  {}
                )
              )
            }
          )
        }
      )
    )
    after going through your question and please correct me if this is not your requirement.
    Also it would be great if you can attach your code snippet so that one can try to debug it easily.

Reply
  • 0
    Certified Lead Developer

    I think there is a problem with the logic used in the save into of the multiple drop-downs. Also I have created a sample code 

    load(
      local!dropdownOneLabels: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
      local!dropdownTwoLabels: {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"},
      local!dropdownOneValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
      local!dropdownTwoValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
      local!tmpDropdownOneLabels,
      local!tmpDropdownTwoLabels,
      local!tmpDropdownOneValues,
      local!tmpDropdownTwoValues,
      local!dropdownOne,
      local!dropdownTwo,
      with(
        {
          a!multipleDropdownField(
            label: "Dropdown One",
            labelPosition: "ABOVE",
            placeholder: "-- Select values in Dropdown One --",
            choiceLabels: if(and(rule!APN_isEmpty(local!dropdownTwo), rule!APN_isEmpty(local!tmpDropdownOneLabels)),
              local!dropdownOneLabels,
              local!tmpDropdownOneLabels
            ),
            choiceValues: if(and(rule!APN_isEmpty(local!dropdownTwo), rule!APN_isEmpty(local!tmpDropdownOneValues)),
              local!dropdownOneValues,
              local!tmpDropdownOneValues
            ),
            value: local!dropdownOne,
            saveInto: {
              local!dropdownOne,
              a!save(
                local!dropdownTwo,
                {}
              ),
              a!save(
                local!tmpDropdownTwoLabels,
                index(
                  local!dropdowntwoLabels,
                  local!dropdownOne,
                  {}
                )
              ),
              a!save(
                local!tmpDropdownTwoValues,
                index(
                  local!dropdownTwoValues,
                  local!dropdownOne,
                  {}
                )
              )
            }
          ),
          a!multipleDropdownField(
            label: "Dropdown Two",
            labelPosition: "ABOVE",
            placeholder: "-- Select values in Dropdown Two --",
            choiceLabels: if(and(rule!APN_isEmpty(local!dropdownOne), rule!APN_isEmpty(local!tmpDropdownTwoLabels)),
              local!dropdownTwoLabels,
              local!tmpDropdownTwoLabels
            ),
            choiceValues: if(and(rule!APN_isEmpty(local!dropdownOne), rule!APN_isEmpty(local!tmpDropdownTwoValues)),
              local!dropdownTwoValues,
              local!tmpDropdownTwoValues
            ),
            value: local!dropdownTwo,
            saveInto: {
              local!dropdownTwo,
              a!save(
                local!dropdownOne,
                {}
              ),
              a!save(
                local!tmpDropdownOneLabels,
                index(
                  local!dropdownOneLabels,
                  local!dropdownTwo,
                  {}
                )
              ),
              a!save(
                local!tmpDropdownOneValues,
                index(
                  local!dropdownOneValues,
                  local!dropdownTwo,
                  {}
                )
              )
            }
          )
        }
      )
    )
    after going through your question and please correct me if this is not your requirement.
    Also it would be great if you can attach your code snippet so that one can try to debug it easily.

Children
  • Thanks Ram, 

    Your solution is close to what we are looking for , but when we nullify the value parameter the 2 dropdowns are going in endless loop,

    (i.e) if A is selected value in B is empty and if  B is selected A becomes empty,

    Hence we tried to nullify value parameter first and save the required values into it, which threw us the below error. 

    Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!multipleDropdownField [line 14]: A multiple dropdown component [label=“Dropdown One”] has an invalid value for “value”. All selected values must be present in the choiceValues array, but value was 1 and choiceValues was .

    We just added a a!save() into your code based on our use case and it threw us the error, attaching the code.

    load(
      local!dropdownOneLabels: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
      local!dropdownTwoLabels: {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"},
      local!dropdownOneValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
      local!dropdownTwoValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
      local!tmpDropdownOneLabels,
      local!tmpDropdownTwoLabels,
      local!tmpDropdownOneValues,
      local!tmpDropdownTwoValues,
      local!dropdownOne,
      local!dropdownTwo,
      with(
        {
          a!multipleDropdownField(
            label: "Dropdown One",
            labelPosition: "ABOVE",
            placeholder: "-- Select values in Dropdown One --",
            choiceLabels: if(and(rule!APN_isEmpty(local!dropdownTwo), rule!APN_isEmpty(local!tmpDropdownOneLabels)),
            local!dropdownOneLabels,
            local!tmpDropdownOneLabels
            ),
            choiceValues: if(and(rule!APN_isEmpty(local!dropdownTwo), rule!APN_isEmpty(local!tmpDropdownOneValues)),
            local!dropdownOneValues,
            local!tmpDropdownOneValues
            ),
            value: local!dropdownOne,
            saveInto: {
              local!dropdownOne,
              a!save(
                local!dropdownTwo,
                {}
              ),
              a!save(
                local!tmpDropdownTwoLabels,
                index(
                  local!dropdowntwoLabels,
                  local!dropdownOne,
                  {}
                )
              ),
              a!save(local!dropdownTwo, local!tmpDropdownTwoLabels),
              a!save(
                local!tmpDropdownTwoValues,
                index(
                  local!dropdownTwoValues,
                  local!dropdownOne,
                  {}
                )
              )
            }
          ),
          a!multipleDropdownField(
            label: "Dropdown Two",
            labelPosition: "ABOVE",
            placeholder: "-- Select values in Dropdown Two --",
            choiceLabels: if(and(rule!APN_isEmpty(local!dropdownOne), rule!APN_isEmpty(local!tmpDropdownTwoLabels)),
            local!dropdownTwoLabels,
            local!tmpDropdownTwoLabels
            ),
            choiceValues: if(and(rule!APN_isEmpty(local!dropdownOne), rule!APN_isEmpty(local!tmpDropdownTwoValues)),
            local!dropdownTwoValues,
            local!tmpDropdownTwoValues
            ),
            value: local!dropdownTwo,
            saveInto: {
              local!dropdownTwo,
              a!save(
                local!dropdownOne,
                {}
              ),
              a!save(
                local!tmpDropdownOneLabels,
                index(
                  local!dropdownOneLabels,
                  local!dropdownTwo,
                  {}
                )
              ),
              a!save(local!dropdownOne,local!tmpDropdownOneLabels),
              a!save(
                local!tmpDropdownOneValues,
                index(
                  local!dropdownOneValues,
                  local!dropdownTwo,
                  {}
                )
              )
            }
          )
        }
      )
    )

    According to our use case , When A dropdown is already selected , and a value in B dropdown is selected, both the choice value and Value parameter of A dropdown should be refreshed & updated to the corresponding values in B, and Vice versa 

  • Hi Vasundaraa,

    Choicevalues should be saved into the value parameter. In the above code, choicelabels are getting saved. Also, choicevalues are null. That's the reason above code is throwing an error.

    Please check the below code snippet. I have made few more modifications. Do let me know if this is not your requirement.

    load(
      local!dropdownOneLabels: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
      local!dropdownTwoLabels: {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"},
      local!dropdownOneValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
      local!dropdownTwoValues: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
      local!tmpDropdownOneLabels: local!dropdownOneLabels,
      local!tmpDropdownTwoLabels: local!tmpDropdownTwoLabels,
      local!tmpDropdownOneValues: local!dropdownOneValues,
      local!tmpDropdownTwoValues: local!dropdownTwoValues,
      local!dropdownOne,
      local!dropdownTwo,
      with(
        {
          a!multipleDropdownField(
            label: "Dropdown One",
            labelPosition: "ABOVE",
            placeholder: "-- Select values in Dropdown One --",
            choiceLabels: if(
              and(
                rule!APN_isEmpty(
                  local!dropdownTwo
                ),
                rule!APN_isEmpty(
                  local!tmpDropdownOneLabels
                )
              ),
              local!dropdownOneLabels,
              local!tmpDropdownOneLabels
            ),
            choiceValues: if(
              and(
                rule!APN_isEmpty(
                  local!dropdownTwo
                ),
                rule!APN_isEmpty(
                  local!tmpDropdownOneValues
                )
              ),
              local!dropdownOneValues,
              local!tmpDropdownOneValues
            ),
            value: local!dropdownOne,
            saveInto: {
              local!dropdownOne,
              a!save(
                local!dropdownTwo,
                {}
              ),
              a!save(
                local!tmpDropdownTwoLabels,
                index(
                  local!dropdowntwoLabels,
                  local!dropdownOne,
                  {}
                )
              ),
              a!save(
                local!tmpDropdownTwoValues,
                index(
                  local!dropdownTwoValues,
                  local!dropdownOne,
                  {}
                )
              ),
              a!save(
                local!dropdownTwo,
                local!tmpDropdownTwoValues
              ),
              if(
                rule!APN_isEmpty(
                  local!dropdownOne
                ),
                {
                  a!save(
                    local!tmpDropdownOneLabels,
                    local!dropdownOneLabels
                  ),
                  a!save(
                    local!tmpDropdownOneValues,
                    local!dropdownOneValues
                  )
                },
                {}
              )
            }
          ),
          a!multipleDropdownField(
            label: "Dropdown Two",
            labelPosition: "ABOVE",
            placeholder: "-- Select values in Dropdown Two --",
            choiceLabels: if(
              and(
                rule!APN_isEmpty(
                  local!dropdownOne
                ),
                rule!APN_isEmpty(
                  local!tmpDropdownTwoLabels
                )
              ),
              local!dropdownTwoLabels,
              local!tmpDropdownTwoLabels
            ),
            choiceValues: if(
              and(
                rule!APN_isEmpty(
                  local!dropdownOne
                ),
                rule!APN_isEmpty(
                  local!tmpDropdownTwoValues
                )
              ),
              local!dropdownTwoValues,
              local!tmpDropdownTwoValues
            ),
            value: local!dropdownTwo,
            saveInto: {
              local!dropdownTwo,
              a!save(
                local!dropdownOne,
                {}
              ),
              a!save(
                local!tmpDropdownOneLabels,
                index(
                  local!dropdownOneLabels,
                  local!dropdownTwo,
                  {}
                )
              ),
              a!save(
                local!tmpDropdownOneValues,
                index(
                  local!dropdownOneValues,
                  local!dropdownTwo,
                  {}
                )
              ),
              a!save(
                local!dropdownOne,
                local!tmpDropdownOneValues
              ),
              if(
                rule!APN_isEmpty(
                  local!dropdownTwo
                ),
                {
                  a!save(
                    local!tmpDropdownTwoLabels,
                    local!dropdownTwoLabels
                  ),
                  a!save(
                    local!tmpDropdownTwoValues,
                    local!dropdownTwoValues
                  )
                },
                {}
              )
            }
          )
        }
      )
    )

    Thanks,

    Hema

  • hi hema,

    thanks for your reply, this code is failing when a value is selected on the second dropdown after selecting values in the first. the code attached to mike's reply is working, but since the multiple dropdown saves one value at a time, my refresh is happening as soon as one value is selected. Please let me know if there is a way to know when the save into is completed for all the user selected values