I am making a generic function to filter City based on State entry and if State field is null, City should be filtered for entered country.
I have bound my addPreSearch to function onCityPreSearch() which is below.
onCityPreSearch = function (formContext) { var stateid = this.readGuid(formContext, this._addressFields.fieldState); var countryid = this.readGuid(formContext, this._addressFields.fieldCountry); var cityCtrl1 = formContext.getControl(this._addressFields.fieldCity); var fetchXML = ""; if (stateid) { fetchXML = ""; } else if (countryid) { fetchXML = ""; } else { fetchXML = ""; } fetchXML = "" fetchXML ""; cityCtrl1.addCustomFilter(fetchXML); };
The scenarios 1 to 3 below are working, 4th doens't work
- The first time form loads and I select a country, it filters city for that Country
- After that, if I select state, it filters city for entered State
- If I change the state, the cities of the changed State are correctly shown
- Now, if I delete the State value, I expect, it should filter and show cities from the entered Country - this doesn't work - it continues to show the cities of the last value I had entered for the State.
What correction do I need to make?
EDiT -
The below screenshot displays the values that are assigned at run time -