I have a select
field type in the Item DocType. Based on the selected value, a number of fields toggle visibility that are dependent on the value of the select field. I have used a custom client script to filter values that appear in these fields based on the selection in the select field using the set_query
filter.
Now, in the list view, I have the same select
field as stated above and need to have the same filter as in the Item form field.
How do I go about this?
1 Like
Were you able to achieve this? I have the same question
1 Like
Hi, there!
No, but figured out a different way to meet the requirements.
A quick query with ChatGPT gave this result, haven’t tested it though.
frappe.listview_settings['Sales Invoice'] = {
onload: function(listview) {
// Listen to changes in the 'Customer' filter
listview.page.add_field({
fieldname: "customer",
label: __("Customer"),
fieldtype: "Link",
options: "Customer",
onchange: function() {
const customer = listview.page.fields_dict.customer.get_value();
// Update the 'Project' filter options based on 'Customer' value
listview.page.add_field({
fieldname: "project",
label: __("Project"),
fieldtype: "Link",
options: "Project",
get_query: function() {
if (customer) {
return {
filters: {
customer: customer
}
};
}
}
});
}
});
}
};
Hope it helps. Here’s the link to the ChatGPT thread.