I have a DocType where it has two fields (dropdowns) Make and Model. I was able to filter the model list based on the selected ‘Make’.
However, in an instance where both make and model is already selected and I go and change the ‘Make’. Now I want to remove the selected item from the ‘Model’ field. Can someone help me achieving this?
I tried adding doc.model = ''
just above the line begins with cur_frm
but that didn’t remove the currently selected value.
Below is the code which filters ‘Model’ when a make is selected.
frappe.ui.form.on('Vehicle', {
make: function(frm) {
//Filter models based on vehicle make
cur_frm.fields_dict['model'].get_query = function(doc) {
return {
filters: {
"parent": doc.make
}
}
}
}
});