Try ERPNext Buy Support Partners Foundation

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