Applying a Filter to the Task Field in the Timesheet Detail Child Table in ERPNext

I am writing this code in a child table named Timesheet Detail, which belongs to the parent doctype Timesheet . The field name for this child table in the parent doctype is time_logs. In this child table, there are two fields: activity_type and task. I want to set a filter on the task field. but its not working . How to set filter for task field .

frappe.ui.form.on(‘Timesheet’, {
employee(frm) {
console.log(‘hi’)
}
});

frappe.ui.form.on(‘Timesheet Detail’, {
activity_type: function(frm, cdt, cdn) {

var data = [“Task 1”, “Task 2”];

                            frm.fields_dict['time_logs'].grid.get_field('task').get_query = function() {
                                return {
                                    filters: {
                                        name: ['in', data]
                                    }
                                };
                            };
                                    frm.refresh_field('time_logs');

}

});

frm.fields_dict['time_logs'].grid.get_field('task').get_query = function(doc, cdt, cdn){
	return {
		filters: {
			name: ['in', data] 
		}
	}
}

Try this; I’ve added a parameter, and it’s working.

1 Like