How to show list of Items Group -> Raw Material only?

Hello,

I am allowing user to select base raw material to use for manufacturing.

I have created a field of Type → Link but when a user go to this field is shows all Items.

Here I only want to show those Items which belong to Raw Material group and have a custom field called is_brightbar should be true.

How to do this?

TIA

Yogi Yang

You can use set_query method to filter the data

ref: erpnext/customer.js at 78851ecb70a46024b7a1995252f5312dfd6e8aac · frappe/erpnext · GitHub

2 Likes

Hello,

Thanks for sharing the link. This meaning I will have to write a Custom Script.

I was hoping that we would be able to set filter when defining Field in DocType.

TIA

Yogi Yang

Hi @YogiYang,

Please check it.
https://frappeframework.com/docs/v13/user/en/guides/app-development/overriding-link-query-by-custom-script

1 Like

@saurabh6790. This is mind blowingly simple just one line of code!! :slightly_smiling_face:

But now I am a bit confused as the documentation link posted by @Solufy shows a lengthy coding style while the link posted by you shows a different coding style.

Just from curiosity which one is better to use?

Actually which one should one use?

Regards,

Hello,

On going through both the links I can say that if you want to filter list just using one single parameter then the link suggested by @saurabh6790 is the way to go by.

If one needs to use multiple parameters for filtering the list then the official documentation as proposed by @Solufy is the way to go by.

TIA

Yogi Yang