multipleDropdownField selection issue

Hi,

I have a multipleDropdownField with the attached code.

I am getting an error when I try to select any additional item from the dropdown.

Can someone give me an idea how to fix the issue. Thanks in advance.

Using the below code while Testing the user interface.

rule input:

lcmIntakeDesignatedBusinesses:

  Discussion posts and replies are publicly visible

  • I see in your a!multipleDropdownField that your value is local!selectedDesignatedBusinesses.dbkey, while the saveInto is local!selectedDesignatedBusinesses. That's not correct, you should save value of the same type. I recommend save the object LCM_IntakeDesignatedBusiness instead of only one field

  • 0
    Certified Senior Developer

    Try This. 

    a!localVariables(
    local!designatedBusiness: {
    'type!{urn:com:appian:types:LCM}LCM_DesignatedBusinesses'('dbkey': 1, 'dbname': "Test-1"),
    'type!{urn:com:appian:types:LCM}LCM_DesignatedBusinesses'('dbkey': 2, 'dbname': "Test-2"),
    'type!{urn:com:appian:types:LCM}LCM_DesignatedBusinesses'('dbkey': 3, 'dbname': "Test-3"),
    'type!{urn:com:appian:types:LCM}LCM_DesignatedBusinesses'('dbkey': 4, 'dbname': "Test-4")
    },
    local!selectedDesignatedBusinesses,
    a!formLayout(
    label: "Form",
    contents: {
    a!sectionLayout(
    contents: {
    a!multipleDropdownField(
    label: "Designated Business/Function",
    labelPosition: "ABOVE",
    helpTooltip: "Designated Business/Function",
    placeholder: "Select a Designated Business/Function",
    choiceLabels: index(local!designatedBusiness, "dbname", ""),
    choiceValues: index(local!designatedBusiness, "dbkey", ""),
    value: local!selectedDesignatedBusinesses,
    saveInto: {
    local!selectedDesignatedBusinesses,

    },
    required: true
    )
    }
    ),

    },
    buttons: a!buttonLayout(
    primaryButtons: {
    a!buttonWidget(
    label: "Submit",
    submit: true,
    style: "PRIMARY"
    )
    },
    secondaryButtons: {
    a!buttonWidget(
    label: "Cancel",
    value: true,
    saveInto: ri!cancel,
    submit: true,
    style: "NORMAL",
    validate: false
    )
    }
    )
    )
    )

  • When the page loads, I will have few values in the below variable 

    local!selectedDesignatedBusinesses

    I have to be in a position to retain those values in addition to new selections.

  • Hi,

    If I re-write saveInto like below, all my previous value are overriding with latest selection.

     ri!lcmIntakeDesignatedBusinesses.dbkey,

  • +1
    Certified Senior Developer
    in reply to swapnar6405

    Try this:

    a!localVariables(
      local!dbkeysFromRi: ri!lcmIntakeDesignatedBusinesses.dbkey,
      local!designatedBusiness: {
        'type!{urn:com:appian:types:LCM}LCM_DesignatedBusinesses'(dbkey: 1, dbname: "Test-1"),
        'type!{urn:com:appian:types:LCM}LCM_DesignatedBusinesses'(dbkey: 2, dbname: "Test-2"),
        'type!{urn:com:appian:types:LCM}LCM_DesignatedBusinesses'(dbkey: 3, dbname: "Test-3"),
        'type!{urn:com:appian:types:LCM}LCM_DesignatedBusinesses'(dbkey: 4, dbname: "Test-4")
      },
      local!selectedDesignatedBusinesses: if(
        a!isNullOrEmpty(ri!lcmIntakeDesignatedBusinesses),
        null(),
        ri!lcmIntakeDesignatedBusinesses.dbkey
      ),
      local!addItems: difference(
        local!selectedDesignatedBusinesses,
        local!dbkeysFromRi
      ),
      local!removeItems: wherecontains(
        difference(
          local!dbkeysFromRi,
          local!selectedDesignatedBusinesses
        ),
        ri!lcmIntakeDesignatedBusinesses.dbkey
      ),
      a!formLayout(
        label: "Form",
        contents: {
          a!sectionLayout(
            contents: {
              a!multipleDropdownField(
                label: "Designated Business/Function",
                labelPosition: "ABOVE",
                helpTooltip: "Designated Business/Function",
                placeholder: "Select a Designated Business/Function",
                choiceLabels: index(local!designatedBusiness, "dbname", ""),
                choiceValues: index(local!designatedBusiness, "dbkey", ""),
                value: local!selectedDesignatedBusinesses,
                saveInto: local!selectedDesignatedBusinesses,
                required: true
              )
            }
          ),
          
        },
        buttons: a!buttonLayout(
          primaryButtons: {
            a!buttonWidget(
              label: "Submit",
              submit: true,
              style: "PRIMARY",
              saveInto: {
                a!forEach(
                  local!addItems,
                  a!save(
                    ri!lcmIntakeDesignatedBusinesses,
                    append(
                      ri!lcmIntakeDesignatedBusinesses,
                      'type!{urn:com:appian:types:LCM}LCM_IntakeDesignatedBusiness'(
                        intakedesignatedbusinesskey: null,
                        intakeheaderkey: null,
                        dbkey: fv!item
                      )
                    )
                  )
                ),
                a!save(
                  ri!lcmIntakeDesignatedBusinesses,
                  remove(
                    ri!lcmIntakeDesignatedBusinesses,
                    local!removeItems
                  )
                )
              }
            )
          },
          secondaryButtons: {
            a!buttonWidget(
              label: "Cancel",
              value: true,
              saveInto: ri!cancel,
              submit: true,
              style: "NORMAL",
              validate: false
            )
          }
        )
      )
    )

    I have saved the desired values (addition/removal) in the rule input on Submit button saveInto 

  • 0
    Certified Lead Developer
    in reply to swapnar6405

    Did you check if the above-mentioned field is a multiple type one? 

  • 0
    Certified Associate Developer

    Hi,

    Try to save all the selected values in the localvariables and while submitting the form append the values to the target variable

  • Thank you so much Sanchit and salute to the login which you have provided to the code.

    It is a great help. 

  • 0
    Certified Lead Developer
    in reply to JayaPrakash Ravipati
    append the values to the target variable

    this is not really correct advice for this use case.

  • Mike,

    Please advise if you are having any other process to handle this case.