I aimed to set the filter dynamically on the list view. It works when I provide the value statically, but it doesn’t function correctly with the asynchronous approach in the Frappe call.
Reference - List
How can I convert the asynchronous frappe.call
to a synchronous method?
Or how should I pass the value dynamically?
At the same time, the frappe.call() is fetching the value properly
frappe.listview_settings['Inventory Summary'] = {
onload: function(listview) {
// the following line is working
//frappe.route_options = {"branch_id": 2};
console.log('list view');
let useremail = frappe.user.get_emails();
let email = useremail[0];
let api_url = "rom_app.restaurant_ops_mgmt.api.get_the_branch_name_for_the_user"
//------------------------------------
frappe.call({
method: api_url,
args: {emailid: email},
callback: function(res) {
let branch__id = res.message.branch_id;
let branch__name = res.message.branch_name;
// the following line is NOT WORKING
frappe.route_options = {"branch_id": branch__id};
listview.refresh();
}
});
//------------------------------------
}
}