How to display data dynamically based on previous selected data

A Score Level 1

Hi,

I have two dropdowns in my interface. Based on first selected dropdown second dropdown has to chaange.

like, First dropdown is 'Country' . If i select the country it should display list of states for that country.

I have created multiple constants for states for each and every country.

My constants are 

APPNAME_COUNTRY - List of countries

APPNAME_COUNTRYNAME1 - list of states for that country

APPNAME_COUNTRYNAME2 - List of states for countryname2

So if i select country i have to populate another dropdown (states) in Interface. So how can i call the constants dynamically. Below is the validation i tried but no luck. Please help.

if (
isnull(ri!APPNAME_Customer_Details.address.country),
null,
cons!BP_+upper(ri!APPNAME_Customer_Details.address.country)
)

Regards,

Sirisha

Regards,

Sirisha

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Senior Developer
    in reply to Timo

    Please check the example

    load(
      local!countryLabelConstant:{"IND","USA","UK"},
      local!countryValuesConstant:{1,2,3},
      local!indStatesConstant:{"TN","AP"},
      local!usaStatesConstant:{"AL","AK"},
      local!ukStatesConstant:{"JK","JL"},
      local!states,
      local!selectedCountry,
      local!selectedState,
      {
        a!dropdownField(
          label: "Country",
          placeholderLabel: "Please select",
          choiceLabels: local!countryLabelConstant,
          choiceValues: local!countryValuesConstant,
          value: local!selectedCountry,
          saveInto: {
            local!selectedCountry,
            a!save(
              local!selectedState,
              NULL
            ),
            a!save(
              local!states,
              choose(
                save!value,
                local!indStatesConstant,
                local!usaStatesConstant,
                local!ukStatesConstant
              )
            )
          }
        ),
        a!dropdownField(
          showWhen: not(
            rule!APN_isBlank(
              local!selectedCountry
            )
          ),
          label: "States",
          placeholderLabel: "Please select",
          choiceLabels: local!states,
          choiceValues: local!states,
          value: local!selectedState,
          saveInto: local!selectedState
        )
      }
    )