Is there a way to filter result when using a fetch from?

I have a custom field that is linked to item which I want to filter it to a certain item category, is there any way to do this using the fetch from value in a link custom field?

for example filtering result to item type raw material.

Found a solution as the following:

Create a custom field using the customize form, then add a custom script like the following:

frappe.ui.form.on("Item", {
	setup: function(frm) {
		frm.set_query("name_of_your_field", function() {
			return {
				filters: [
					["Item","item_group", "in", ["option1", "option2"]]

it will filter the result showed to the user.


This topic was automatically closed after 4 days. New replies are no longer allowed.