I have a doctype where the records are displayed in list view according to the conditions i have written in server side script, Example i have a doctype where i am fetching the records according to the query and displaying them in the front end
now when i try to filter the record
it is not filtering, can anyone tell me what might be the issue
see basically this code
frappe.listview_settings[‘Fimer Post Training Evaluation Form Test’] = {
refresh: function(listview) {
frappe.call({
method: ‘hrms.hr.doctype.fimer_post_training_evaluation_form_test.custom.get_evaluation_forms_for_user’,
callback: function(response) {
if (response.message && response.message.forms) {
var forms = response.message.forms;
var count = response.message.count;
listview.page.wrapper.find(‘.list-count’).text(${count} of ${count}
);
listview.data = forms;
listview.render();
listview.page.wrapper.find(‘.list-pagination’).css(‘display’, ‘none’);
} else {
listview.page.wrapper.find(‘.result’).html(“
No forms available.
”);
}
},
error: function(xhr, textStatus, error) {
console.error(“Error fetching forms:”, error);
listview.page.wrapper.find(‘.result’).html(“
Error fetching evaluation forms.
”);
}
});
}
};
import frappe
@frappe.whitelist()
def get_evaluation_forms_for_user():
session_user = frappe.session.user
if session_user == ‘divya.j.ext@fimer.com’ or session_user == ‘Administrator’:
# If the user is hr@gmail.com, fetch all records
forms = frappe.db.sql(“”"
SELECT * FROM tabFimer Post Training Evaluation Form Test
“”“, as_dict=True)
else:
# For other users, fetch records based on ownership or reporting
forms = frappe.db.sql(”“”
SELECT * FROM tabFimer Post Training Evaluation Form Test
WHERE owner = %s OR reports_to = %s
“”", (session_user, session_user), as_dict=True)
# Get the count of forms
count = len(forms)
return {
"forms": forms,
"count": count
}
is giving me exact records as requirement in my list view but
but for this code
this filter is not working , can anyone tell me why? in this two records the if i try to filter trainer name it is showing me all the two fetched records and for the code you gave it is not displaying any record, can you check again