Distinct Value

Distinct Value

Hi All,

I am trying to create dynamic drop down list in my form.

Form : A - Location
===============
State
City
Area
Zipcode.

The nature of the form is, all 4 fields altogether will give you unique value. But for a given column, it will be duplicate value. (ex: one state may have many cities, one city may have many areas etc..)

Form B: Blood Bank Register
======================
For this form, I need to create State, City, Area drop down list dynamically. I have created simple drop down fields.

State
City
Area
Zipcode

 For example on load, it should populate the STATE drop down with Unique records from Location form. Below is the code and it works fine.

on load
ListValue = Location.distinct(State);
clear State;
State:ui.add(ListValue);

Now Under State field -> On user Input, i have given below code to populate Cities based on selection of State.

City_list = List();
City_rec  =  Location  [State == input.State];
City_list.addall(City_rec.City.getall());
for each CityName in City_list
{
    City:ui.add(CityName);
}

It works fine, but the issue is, City drop down is shoing duplicate records. Can someone help me to figure out where exactly we can put DISTINCT function to get only unique value of Cities for a given State?