Try ERPNext Buy Support Partners Foundation

How to Filter a list based on selection of another list item

I have created a master Brand Group in which two fields are there one is a linked of Brand Master and second one is a data field which denotes the name of Brand Group Master.

I need to customize the Item Form where I want Brand Group list should display the filtered data. First I will select Brand then on the basis of Brand selection, Brand Group drop down should show only those data which are belong to the selected Brand.

Issue is my Brand Group list is showing all data. I have added both fields Brand and Brand Group. Both fields are created as Link type field. Please suggest.

i think this should help you
https://kb.erpnext.com/kb/customize/managing-dynamic-link-fields

I tried by adding link field with options as doctype as suggested in Managing Dynamic Link Fields article. But it is showing me drop down of all document type. whereas I need a list of Brand Master, and on the selection of Brand Master i need to filter our Brand Group Design List.

Try using the following code

cur_frm.fields_dict[‘brand_group’].get_query = function(doc) {
return{
filters:[
[‘brand’, ‘=’, doc.brand]
]
}

2 Likes

Thank you for your help neilLasrado. Your solution has been worked for me. Just a comment - I just need to add missing closing parenthesis } at the end of the code.

@Navneet_Gupta Ma Bad… Discuss needs a syntax checker. Anyways good you figured it out.

Thank you very much

1 Like

Hi, this link is broken
https://kb.erpnext.com/kb/customize/managing-dynamic-link-fields

Someone can provide the examples or codes please.

1 Like

https://erpnext.com/docs/user/manual/en/customize-erpnext/articles/managing-dynamic-link-fields

this link is not opening. I have a similar challenge

Hi,

Check this: https://docs.erpnext.com/docs/user/manual/en/customize-erpnext/articles/dynamic-link-fields