Set filter to link based on another field (In a child table)

When someone selects a “Marketplace”, the “Category” should filter for only the ones with this marketplace. Currently doing a client side script. Any better way to do this?

My child table:

The Category column is linked to this custom doctype:

My current non-working script: (I have gone as far as getting an action happening when the “Marketplace” field is changed inside the child table. It does not set the filter to the “Category” column)
image

Hi @plague69,

As per your scenario,

Similarly, we prepared a few pieces of logic. please check the video.

Client Script:

frappe.ui.form.on("Test DocType", {
  onload: function (frm) {
    frm.set_query("item_code", "test_child", function (doc, cdt, cdn) {
      let row = locals[cdt][cdn];
      return {
        "filters": {
          "item_group": row.item_group
        },
      };
    });
  },
});

Output:

I hope this helps.

Thank You!

1 Like

@NCP absolute legend. Thank you. I was very stuck on how to get the row as well. This example explains many aspects!