Dynamic picklist

Dynamic picklist

Hi,

I have three form and each are inter related by lookup field --Market-- .

Market Form ;

Market 
ID

County Form:

County Name
Market Name--( lookup field form Market Form)
Fips
State

MVPD Form ;


MVPD Name
Market -- ( lookup field from Market form)
county ( look up field from county form)


I am trying to create  dynamic picklist for county field in the MVPD form . When user select Market name of the MVPD form then county form will populate only those county name that are  related to the  County Form  data with respect to selected market .

I am trying to use below on user input but not working


if ( input.Market != null)
{
dat  =  County  [county_Market = input.Market] sort by  CountyName ;

clear County;

County:ui.add(dat.CountyName.getall());

}