Client Script on the Sales Order

Can anyone help me with a Client Script of Frappe ERPNext on the Sales Order where I have created a Customs Field in the Sales Order as Product Group having Drop Down Option as “Cat Products, Dog Products” which is the same as the Item group, so once the User selects the Cate Products, then in the Item Child Table, the Item of Only Cat Products should get display and in case user select “Dog Products”, then it should display Items of only the Dog Products? Please note that this Item Group is my Parent Item Group and not the Child Group.

Hi @jitendra,

Please apply the client script for that.

frappe.ui.form.on("Sales Order", {
    refresh: function (frm) {
        frm.trigger('product_group');
    },
    product_group: function (frm) {
        frm.set_query("item_code", "items", function (doc, cdt, cdn) {
            let row = locals[cdt][cdn];
            return {
                "filters": {
                    "item_group": frm.doc.product_group
                },
            };
        });
    }
});

Please check your field name and set it according.

Thank You!

Thanks a Lot, @NCP for always helping us

@NCP, I have tried to use the same Client Script, but it is not working. Just to update you I have created a Custom Field in the Sales Order with the field name as custom_product_group, with Input Type as Select- and Provided the Options as “Cat Products”, and “Dog Products” and these are the same as my main Parent Iten Group and against this Parent Item Group I have created the Child Item Group

Hi @jitendra,

Please check it.

Thank You!

@NCP, Thank you so much. Yes, it is working.

@NCP, It was a happy moment to meet you at the ERPNext Conference and congratulations on winning the Best Contributor in a Discussion Forum.

Hi @jitendra,

I’m really glad we met at the ERPNext Conference! :blush:
Thank you so much :+1: