Appian Community and Appian Academy are being upgraded. As a part of the upgrade, Appian Community is currently in read-only mode, and user registration is disabled until August 3. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!

The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.

Select countries based on Regions

Certified Associate Developer

Hi folks,

New to Appian!

I need to create an interface which will allow a user to select/unselect the countries based on regions.

Description:

1. An Interface is having 2 dropdown lists first Region List and second is Countries list. (created)

2. All countries belongs to selected region must be selected automatically whenever an user selects a region.

3. An user can unselect one or more country(s) from the countries list if he wants.

Looking for a detailed suggestion or solution to implement this functionality.

Thank you in advance!

Regards,

Shubham Kumar

  Discussion posts and replies are publicly visible

Parents
  • This code snippet should help

    a!localVariables(
      local!regions: {
        { id: 1, name: "Region 1",  },
        { id: 2, name: "Region 2",  },
        { id: 3, name: "Region 3",  }
      },
      local!countries: {
        { id: 1, name: "Country 1", regionId: 1 },
        { id: 2, name: "Country 2", regionId: 1 },
        { id: 3, name: "Country 3", regionId: 1 },
        { id: 4, name: "Country 4", regionId: 2 },
        { id: 5, name: "Country 5", regionId: 2 },
        { id: 6, name: "Country 6", regionId: 2 }
      },
      local!selectedRegion,
      local!selectedCountries,
      {
        a!multipleDropdownField(
          label: "Region",
          choiceLabels: local!regions.name,
          choiceValues: local!regions.id,
          value: local!selectedRegion,
          saveInto: {
            local!selectedRegion,
            a!save(
              local!selectedCountries,
              a!flatten(
                index(
                  local!countries.id,
                  wherecontains(
                    tointeger(local!selectedRegion),
                    tointeger(local!countries.regionId)
                  ),
                  {}
                )
              )
            )
          },
          placeholder: "---Country---"
        ),
        a!multipleDropdownField(
          label: "Country",
          choiceLabels: a!flatten(
            index(
              local!countries.name,
              wherecontains(
                tointeger(local!selectedRegion),
                tointeger(local!countries.regionId)
              ),
              {}
            )
          ),
          choiceValues: a!flatten(
            index(
              local!countries.id,
              wherecontains(
                tointeger(local!selectedRegion),
                tointeger(local!countries.regionId)
              ),
              {}
            )
          ),
          value: local!selectedCountries,
          saveInto: local!selectedCountries,
          placeholder: "---Country---"
        )
      }
    )

Reply
  • This code snippet should help

    a!localVariables(
      local!regions: {
        { id: 1, name: "Region 1",  },
        { id: 2, name: "Region 2",  },
        { id: 3, name: "Region 3",  }
      },
      local!countries: {
        { id: 1, name: "Country 1", regionId: 1 },
        { id: 2, name: "Country 2", regionId: 1 },
        { id: 3, name: "Country 3", regionId: 1 },
        { id: 4, name: "Country 4", regionId: 2 },
        { id: 5, name: "Country 5", regionId: 2 },
        { id: 6, name: "Country 6", regionId: 2 }
      },
      local!selectedRegion,
      local!selectedCountries,
      {
        a!multipleDropdownField(
          label: "Region",
          choiceLabels: local!regions.name,
          choiceValues: local!regions.id,
          value: local!selectedRegion,
          saveInto: {
            local!selectedRegion,
            a!save(
              local!selectedCountries,
              a!flatten(
                index(
                  local!countries.id,
                  wherecontains(
                    tointeger(local!selectedRegion),
                    tointeger(local!countries.regionId)
                  ),
                  {}
                )
              )
            )
          },
          placeholder: "---Country---"
        ),
        a!multipleDropdownField(
          label: "Country",
          choiceLabels: a!flatten(
            index(
              local!countries.name,
              wherecontains(
                tointeger(local!selectedRegion),
                tointeger(local!countries.regionId)
              ),
              {}
            )
          ),
          choiceValues: a!flatten(
            index(
              local!countries.id,
              wherecontains(
                tointeger(local!selectedRegion),
                tointeger(local!countries.regionId)
              ),
              {}
            )
          ),
          value: local!selectedCountries,
          saveInto: local!selectedCountries,
          placeholder: "---Country---"
        )
      }
    )

Children