set_query for link field in page

hello everyone,

I’m making a page that has 4 link fields but one need to filter it values using the value in the others.

Normally a use set_query function in a doctype and i was searching in ERPNext and found a parameter named filter.

How can i filter the values of link field 2 using the value in link field 1 in a page?

Example Code:

var classroom = frappe.ui.form.make_control({
		parent: wrapper.body.find(".classroom"),
		df: {
			fieldtype: "Link",
			options: "ClassRooms",
			fieldname: "classroom",
			placeholder: "Class Room"
		},
		only_input: true
	});

var teacher = frappe.ui.form.make_control({
		parent: wrapper.body.find(".teacher"),
		df: {
			fieldtype: "Link",
			options: "Teachers",
			fieldname: "teacher",
			placeholder: "Teacher"
		},
		only_input: true
	});

filter all the teacher that has a class in the classroom selected. For example

In this case you can’t use filter becuase its a static function, you can use get_query to return the filter options though.

Thanks for your answer. Now It’s working. +1

1 Like

Hi @narcisonunez please give us your solution? I need to use get_query for page, but I not sure where I will put it to.
Thanks .