Removing multiple occurances in picklist

Removing multiple occurances in picklist

Hi, I have a form with a list of cities and countries and want to create a picklist with a unique list of countries. The idea is that the user will choose a country and then only cities in that country will be displayed for selection in the next picklist. I want to avoid creating a country list to filter the city and country form to faciliate admin.

This seems to be an old problem, there are a few postings and sitll no funcion to list only unique entries. I have the following code "on load" in the form:


clear Pa_s; >> this is the name of the field used for the picklist

for each thispais in Centros >> thispais is a variable, CEntros is the form with cities and countries in it
{
    if (!(input.Pa_s.toString().contains(thispais.Pais))) >> this converts the picklist to a string, then checks if present country is in that list??
    {
        Pa_s:ui.add(thispais.Pais); >> is not, add the present country
    }
}






Pa_s:ui.add("Test ending");

This seems correct and there are no errors, but it doesnt work. All i get is a list of everything. It is as if the contains() cannot find the present country in the picklist and adds something each loop

Can anyone please help: both city and country are defined as SINGLE LINE with 255. The data was replicated in EXCEL and imported so the text list correct.

many thanks