Filtered LINK field list

what i have to do is create a file in the item master, to select another item as Pacakaging,

I created a LINK field (package) to Item, but i need that this filed swows only Item with a specific item_group field value.

I think that I have to create a customjs for this, but I don’t understand where and how to interact with form and fields.

Anyone can help me?



Go to Custom Script > New. Select DocType as Item and write a set_query script for your field -

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

Thanks it works!!!

Two questions:

  • Where the custom scripts are saved on the system? Because I verify according to manual on apps/erpnext/erpnext/Stock/Item/item.js but I can’t find the js code.

  • I’t possible to eliminate the option “Create New Item” in this specific Link field?


Custom Scripts have their own doctype by the same name. To preserve them add Custom Script to your fixtures in file in your custom app so that it won’t be overwritten by update.

Later on executing bench export-fixtures in your bench instance i.e. (your folder normally named frappe-bench) all mentioned in fixtures will be exported into a JSON.

1 Like