How to filter DocType for Dynamic Link in Child Table?

Hi everyone, as per the title above, does anyone know how to filter the DocType choices for Dynamic Link in a Child Table?

Below is a screenshot of the child table in Employee Doctype

I wanted to filter the ‘Lifecycle’ field in the table to only: ‘Job Applicant’, ‘Job Offer’, ‘Employee Transfer’, ‘Employee Promotion’, 'Employee Separation’

.
Below is my attempted custom script which didn’t work

frappe.ui.form.on('Employee Lifecycle', {
    setup: function(frm, cdt, cdn) {
        frm.set_query('lifecycle', function() {
            return {
                'filters': {
                    'name': ['in', ['Job Applicant', 'Job Offer', 'Employee Transfer', 'Employee Promotion', 'Employee Separation']],
                }
            };
        });
    }
});

This didn’t work either

frappe.ui.form.on('Employee', 'employee_lifecycle', function(frm, cdt, cdn) {
    frm.set_query('lifecycle', function(frm, cdt, cdn) {
        return {
            'filters': {
                ID: 'Job Applicant' || 'Job Offer' || 'Employee Transfer' || 'Employee Promotion' || 'Employee Separation'
            }
        }
    })
})

I use this script on Item’s refresh event.

frappe.ui.form.on("Item", {
	refresh: (frm) => {

		frm.fields_dict['ld_urunagaci'].grid.get_field('ld_parca_tipi').get_query = function(doc, cdt, cdn) {
			return {    
				filters:[
					['parent_item_group', '=', 'Alt Parça']
				]
			}
		};.........
1 Like

I hope this link will help you.