Filter based on child table custom field

Filters can be in this format:

filters: [
[“DocType”, “docfield”, “operator”, “value”]
]

I need “value” to reference a child table field in this script:

cur_frm.fields_dict[‘multi_tc’].grid.get_field(‘mt_title’).get_query = function(doc) {
return {
filters: [[
‘Terms and Conditions’, ‘type’, ‘=’, ???
]]
}
};

The child table name is “multi_tc”, the field name is “mt_type”.

I’ve tried SO MANY different things. Please help.

Hi @Dbone ! Try this:

 cur_frm.fields_dict['multi_tc'].grid.get_field('mt_title').get_query = function(doc, cdt, cdn)
 {
                var d = locals[cdt][cdn];
                return {
                    filters: [[
                            'Terms and Conditions', 'type', '=', d.mt_type
                    ]]
                }
 };

Let me know if this works. Thanks!

3 Likes

It works!!!

Out of sheer frustration though I changed my setup so that I didn’t need to reference the child table for the filter, which made it easier for me to find a solution. I think I like that setup better, but I’ll use yours for another customization I have planned.

Thank you!

Here is the code I used to filter on a custom field not in a child table:

cur_frm.fields_dict['multi_tc'].grid.get_field('mt_title').get_query = function(doc) {
    return {
        filters: [[
            'Terms and Conditions', 'type', '=', doc.type_select
        ]]
    }
};
1 Like