Dependent drop down not working dynamically

Certified Associate Developer

Hi All,

As part of practice and POC purpose. There was requirement like i have created three drop down fields on UI and also there are also Three tables created DB(Tables- States, Cities, Towns).

Sates- drop down and City-Drop down working as expected based on selected state value cities were displaying but based on selected City value towns drop down field values not showing up.

null parameter was passing when i checked local variables. i tried different ways but not able to achieve this.

could you please help on this.  

below code for reference

a!localVariables(
local!stateData: rule!KT_getStateDataById(),
local!stateName: property(local!stateData, "state",null),
local!stateId: property(local!stateData,"id",null),
local!cityname: rule!KT_getCityByStateId(stateId:ri!stateid ),

 local!townname: rule!KT_getTownNameByCityId(cityid: ri!cityId),

{
a!sectionLayout(
label: "",
contents: {
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!dropdownField(
choiceLabels: local!stateName,
choiceValues: local!stateId,
label: "States",
labelPosition: "ABOVE",
placeholder: "--- Select a Value ---",
value: ri!stateid,
saveInto: {
ri!stateid,
a!save(ri!cityName,null)
},
searchDisplay: "AUTO",
validations: {}
)
}
),
a!columnLayout(
contents: {
a!dropdownField(
choiceLabels: local!cityname,
choiceValues: local!cityname,
label: "Cities",
labelPosition: "ABOVE",
placeholder: "--- Select a Value ---",
value: ri!cityName,
saveInto: {
ri!cityName,

},
searchDisplay: "AUTO",
validations: {}
)
}
),
a!columnLayout(
contents: {
a!dropdownField(
choiceLabels: local!towname,
choiceValues: local!towname,
label: "Towns",
labelPosition: "ABOVE",
placeholder: "--- Select a Value ---",
value: ri!townName,
saveInto: {ri!townName},
searchDisplay: "AUTO",
validations: {}
)
}
)
}
)
}
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi Kishore,
    In the second drop-down, "Cities", you are saving the 'city name'. However, in the query rule to retrieve the town name, you are passing the 'city ID' instead of the selected city name. 

    I recommend indexing city names and city IDs in a manner similar to how you indexed state names and state IDs. Utilize the indexed city names and city IDs for drop-down choice labels and values, respectively. Save the city ID instead of the city name to populate the town names.

Reply
  • 0
    Certified Lead Developer

    Hi Kishore,
    In the second drop-down, "Cities", you are saving the 'city name'. However, in the query rule to retrieve the town name, you are passing the 'city ID' instead of the selected city name. 

    I recommend indexing city names and city IDs in a manner similar to how you indexed state names and state IDs. Utilize the indexed city names and city IDs for drop-down choice labels and values, respectively. Save the city ID instead of the city name to populate the town names.

Children