Hi,
I tried to use MultiSelectDialog with custom query method as following code:
//Second Category
frappe.ui.form.on(“Item”, {
add_second_category: function(frm){
let query_args = {
//Backend method that get’s called and returns the Categories
query: “masar_oldtimer.custom.item.item.second_category_query”,
filters: {‘item_code’: frm.doc.item_code}
}
var s = new frappe.ui.form.MultiSelectDialog({
doctype: “Item Second Category”,
target: me.frm,
setters: {
first_category: “”,
second_category: “”
},
add_filters_group: 1,
columns: [“name”, “first_category”],
get_query() {
return query_args;
},
primary_action_label: “Get Category”,
action(selected_categories) {
frappe.call({
method: “masar_oldtimer.custom.item.item.insert_selected_second_category”,
args: {
selected_categories: selected_categories
},
callback: function(r) {
$.each(r.message, function(i, d) {
var row = frappe.model.add_child(cur_frm.doc, “Item Second Category Value”, “second_category”);
row.second_category = d.second_category;
refresh_field(“second_category”);
});
}
});
s.dialog.hide();
}
})
}
});
but i got the result as empty rows
Any advice, please?