Filter Link field based on child table value`

Hi,

I have doctype named x it has link field link and it has data field data and this link field is linked to doctype y and y has child table child this child table has column data same data in x so when ever i enter data i wish to filter link based on the data in child.

That is let

y has 2 rows

  1. has title y_1 and it is child table child has data with value shahid
  2. has title y_2 and it is child table child has data with value varun

and now i go to doctype x when ever i enter shahid in data field i want to show Y_1 in link.

hope my doubt was clear

can any one help me with this please

It’s a little bit confusing but looking at your title, you want to add a filter on any of your link fields.
you can use - set_query for it.

e.g.

frm.set_query("fieldname", function() {
			return {
				filters: [/* your filters */]
			}
		}) 

OR

frm.set_query("fieldname", function() {
			return{
				query: "query_path"
			}
		});

you can found many such examples in erpnext/frappe app code.

Also check this - Overriding Link Query By Custom Script

1 Like

@Sangram thanks for you help i found the solution with help of you and with this also

expect help like this in feature thanks