How to apply filter to child table link fields

I have a long list of Items, some of them are service lists and some are equipments. Whenever we prepare a quotation the quotation items child table fetches from all the item lists. In our case we only use service items for quotation, If there’s a way to apply a custom filter to show only service items from servies item group in quotation form it’ll be great

Thanks,

Hi @girumtibebu,

That for, please apply the client script for Quotation.

frappe.ui.form.on('Quotation',  {
    refresh: function(frm) {
        frm.set_query("item_code", "items", function (doc, cdt, cdn) {
          return {
            "filters": {
              "item_group": "Services"
            },
          };
        });
    }
});

Output:

Thank You!

2 Likes

@NCP Thank you!.
Just curious on how the filtering works performance wise, does it cache all the items first and do filtering locally? How many requests does it make to the database?

Hi @girumtibebu,

Please check the documentation of Overriding Link Query By Custom Script.

I hope this helps.

Thank You!

1 Like

Great. That cleared it out for me.
Thanks.