How to apply filter in child table according to other child table value

Screenshot from 2023-10-18 03-41-53

i want to apply filter on Support name according to selected value in Support category.

You can insert the following script in your JS or Client Script.

frm.set_query("field_name", "child_table_name", function() {
	return {
		filters: {
			'is_sales_item': 1, // Replace this with your filter
		}
	}
});

my child table name is support_table

This is my query from js file to set filters
Screenshot from 2023-10-26 10-57-39

But is not working

filter is not passing in api

Set the filter in your child table field event.

frappe.ui.form.on('Support Table', {
	support_type:function(frm,cdt,cdn){
               var row = locals[cdt][cdn];
               frm.set_query('specific_support_type','support_table', function(){
                      return {
                             filters: {
                                   'Support Type' : row.support_type
                             }
                      }
               }
        }
});

This filter needs to implemented in the Parent doc.

frappe.ui.form.on(<ParentDoctype>, {
    onload: function(frm) {
		frm.set_query('<child_tables_link_fieldname>', '<fieldname_of_childtable_in_parentdoc>', ()=>{
		    return{
		        filters:{
		            //condition here
		        }
		    }
		})
	}
})

Refer to the official documentation frm-set-query

1 Like

thanks @SanaullaHaq ,
it works