Fetch all states in dropdown if no country is selected
Question
Application Type
Reactive

I have 2 dropdowns Country and state.

If no country is selected state dropdown should populate all states in it.But if any of the country is selected, state dropdown should have states which belong to that country only. I am unable to implement this logic.

Hello Neha,

I checked your OML you are doing something wrong
instead of using Boolean variable you will save the country id there in the local one and pass that as variable to country dropdown



In the aggregate write this

If(Countryid<>NullIdentifier(),State.CountryId=Countryid,True)

for reference I have Attached OML and URL

https://akshayproject.outsystemscloud.com/FetchingDataOnDemandExercise/EmployeeDetail?_ts=637813461045778051

may be this will helps you, 

NOTE: make sure while bootstrapping one state name not belongs to  two country
i.e. Country: INDIA state: Maharashtra , Country: Brazil state : Maharashtra

Thanks and Regards,

Akshay Deshpande

FetchingDataOnDemandExercise.oml

Hi Neha,

normally it should work if for the State data request (aggregate / data action) you include  a condition in the filter like this:

  • IF(Country.Id = nullidentifier(), True, State.CountryId = InputCountryId

can you show what you have implemented so far?

Hi Neha Sheikh ,

As per your requirement I have implemented a logic and here I have attached the OML for your reference. If you still have any quires, then share your implemented logic. 

Samplecountry_state selection.oml

Thanks for the reply guys.

Solutions did not work for me. I am attaching my OML for your reference.Initially all states are fetched in this logic but when selecting country the logic is not working. 

FetchingDataOnDemandExercise.oml

Hello Neha,

I checked your OML you are doing something wrong
instead of using Boolean variable you will save the country id there in the local one and pass that as variable to country dropdown



In the aggregate write this

If(Countryid<>NullIdentifier(),State.CountryId=Countryid,True)

for reference I have Attached OML and URL

https://akshayproject.outsystemscloud.com/FetchingDataOnDemandExercise/EmployeeDetail?_ts=637813461045778051

may be this will helps you, 

NOTE: make sure while bootstrapping one state name not belongs to  two country
i.e. Country: INDIA state: Maharashtra , Country: Brazil state : Maharashtra

Thanks and Regards,

Akshay Deshpande

FetchingDataOnDemandExercise.oml

How do we do that in traditional web applications?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.