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
![image.png](https://mail.google.com/mail/u/0?ui=2&ik=56dcace36f&attid=0.1&permmsgid=msg-a:r-2260126413955199737&th=18e50ec8bfb0d70e&view=fimg&fur=ip&sz=s0-l75-ft&attbid=ANGjdJ8MKJbYV8IEPdaMbAP6e2NguW38GN-0sH0FT4_riwlM6IPZSO3Bg8sFMQkIIs5psQLlNqmMjqc_DhhWkx_4_wohcqQvguDKITU61fj-xPtOHABbQYiTbaTHi1M&disp=emb&realattid=ii_ltwr4uqg0)
but for this code
![image.png](https://mail.google.com/mail/u/0?ui=2&ik=56dcace36f&attid=0.2&permmsgid=msg-a:r-2260126413955199737&th=18e50ec8bfb0d70e&view=fimg&fur=ip&sz=s0-l75-ft&attbid=ANGjdJ8_WteQJd-G5BbhcuLcI9UuOhml6TCD5pTob8_w_SHD7151TZdqOXlx8xHSBUab_b-3qMgIdfLZMTLY_J_PHR0dQlI-HTWw7unm0aCi4T6-6tCvPnxj2Vv5uzM&disp=emb&realattid=ii_ltwr59dq1)
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