How to set filter in useFrappeGetDocCount?

 let filters: any[] = [];

filters =searchQuery || status || priority ? [
[“task_name”, “like”, %${searchQuery}%],
[“status”, “like”, %${status}%],
[“priority”, “like”, %${priority}%]
] :
const { data: totalRecords } = useFrappeGetDocCount(‘CG TaskDefinition’, {
filters: filters
});
it is not working, Someone can tell me what was the wrong here.

Foramt of filter looks incorrect.

Try:

let filters: any[] = [];

// Check for searchQuery, status, and priority and build filters accordingly
if (searchQuery) {
    filters.push(["task_name", "like", `%${searchQuery}%`]);
}
if (status) {
    filters.push(["status", "like", `%${status}%`]);
}
if (priority) {
    filters.push(["priority", "like", `%${priority}%`]);
}

// Use the useFrappeGetDocCount hook with the constructed filters
const { data: totalRecords } = useFrappeGetDocCount('CG TaskDefinition', {
    filters: filters.length > 0 ? filters : undefined
});

#RespectQuestion #EncourageNewUser