How to auto populate second dropdown base on item selected from first drop down

Good evening guys
i have a custom form staff with two dropdowns fields “states” and “cities”. I want to populate specific cities belonging only to the state selected in the first dropdown. I’m new to erpnext so I really need your help

try below (assuming these fields are in parent document):

frappe.ui.form.on("CustomForm",{
	setup: function(frm) {
		frm.set_query("city", function(doc) {
			return 	{filters:{"state":doc.state}}
		});
	},

});
1 Like

thank you for your response.
is still not working. i’m getting this error after running it
pymysql.err.InternalError: (1054, “Unknown column ‘tabLGA.state_of_origin’ in ‘where clause’”)
below is my code:
frappe.ui.form.on(“Employee”,{
setup: function(frm) {
frm.set_query(“lga”, function(doc) {
return {filters:{“state_of_origin”:doc.state_of_origin}}
});
},

});

lga: is the child table name on parent table “Employee”
state_of_origin: child table name on the parent table “Employee”
i have LGA child doctype and State child doctype. I linked state to lga and I also created the two fields for lga and state on the parent document.
i appreciate your help

Hello guys. i have not gotten solution for this. pls I need more ideas on how to solve it

yes see this https://docs.erpnext.com/docs/user/manual/en/filter-options-in-select-field.

but the question now is how to make it work in the list view of any related Doctype?

Hi @tayeb_rashed:

Check this :slight_smile:

Hope this helps.