Dynamic lookups fields

Dynamic lookups fields

Hi,

I have 2 dropdown lookup fields. I want the choice in the first field to dictate the second field. I'm trying to use ui.add however in this case I cant use text for the constraints - I have to fetch the IDs as the fields are lookups. Can anyone help with this?

So far i have something like this;

liste = List();
if(Field_A = "Europe")
{
liste.add("Germany");
        liste.add("France");
}
Field_B:ui.add(liste);