Copy link to clipboard
Copied
I have 2 dropdown lists. One is named City and the other is State. I want to populate the City with a list of specific cities based and the selected State. I have read several posts in the discussions and I have used the codes in them. However, the validation keeps rejecting the code saying there is an error in the code. I can't see where there is an error. Here is the code:
if(event.value == " ")
this.getField("Trip.Origin.State.Row1").setItems([" "]);
//Illinois
else if(event.value == "IL")
this.getField("Trip.Origin.State.Row1").setItems([" "]);
//Indiana
else if(event.value == "IN")
this.getField("Trip.Origin.State.Row1").setItems(["Butler",”Burns Harbor”,"Crawfordsville","East Chicago"]);
//Kentucky
else if(event.value == "KY")
this.getField("Trip.Origin.State.Row1").setItems(["Ghent"]);
//Michigan
else if(event.value == "MI")
this.getField("Trip.Origin.State.Row1").setItems(["Monroe"]);
//Ohio
else if(event.value == "OH")
this.getField("Trip.Origin.State.Row1").setItems(["Cleveland",”Coshocton”,"Cuyahoga Heights",”Middletown”,"Newburgh Heights",”Zanesville”]);
//Pennsylvania
else if(event.value == "PA")
this.getField("Trip.Origin.State.Row1").setItems([“Butler”,"Sharon","Wheatland"]);
else this.getField("Trip.Origin.State.Row1").clearItems();
Copy link to clipboard
Copied
Different quotes can happen if you use text editors to copy/paste text like 'Word'.
If you want to show cities when you select state then you need to use script in "State" field not '"City" (you can use script as validation). Also make sure you are setting items in correct field, for example in your script you are setting items in "Trip.Origin.State.Row1" but if you use script in "State" field then you need to change that so it set items in "City" fields.
Copy link to clipboard
Copied
You are using two different types of quote marks, see this: “Butler”, "Sharon" , fix that, and it will work.
Copy link to clipboard
Copied
I've only have 1 button on my keyboard for quote marks. How am I getting two different quote marks?
Copy link to clipboard
Copied
Do I run this in the City's custom validation script or the custom calculation script? I've tried in the validation script, but nothing happens. I don't get any choices in the City field regardless of which State I choose.
Copy link to clipboard
Copied
Different quotes can happen if you use text editors to copy/paste text like 'Word'.
If you want to show cities when you select state then you need to use script in "State" field not '"City" (you can use script as validation). Also make sure you are setting items in correct field, for example in your script you are setting items in "Trip.Origin.State.Row1" but if you use script in "State" field then you need to change that so it set items in "City" fields.
Copy link to clipboard
Copied
Thanks. Working great now.

