Try ERPNext Buy Support Partners Foundation

Load list view with selected rows

I want initial listview of a doc to be loaded with some of the rows only. So, I am having frappe.call which calls method that gets data using frappe.db.sql having conditional query. This call returns proper rows. Now I want to load the listview of the doc with this result. But it is not loading.

Here is my code.

frappe.listview_settings[‘Activity Tracker’] = {
onload: function (listview) {
frappe.call({
method:“sample_app.sample_app.doctype.activity_tracker.activity_tracker.get_activity_tracker_list”,
callback: function( r ) {
console.log(r.message);
listview.data = r.message;
listview.refresh();
}
});
}
}

Where am I going wrong?

can try through hook to restrict rows visible to user, then listview need not br customised
https://frappe.io/docs/user/en/guides/basics/hooks

permission_query_conditions = {
    "{doctype}": "{dotted.path.to.function}",
}
has_permission = {
    "{doctype}": "{dotted.path.to.function}",
}

yes… solved by this way before some days

dotted.path.to.function what is mean ?
can you help me i need to write script or query to show all recrods in the listview if it not has status== "final approval "

In hooks.py you have to specify the path of py file in which you with write method for listview. Path hierarchy from the app folder drilled down to py file.
i.e. Appname.Appname.doctype.docname.docname

thanks too much you help me .
can you explain any method for listview ?
regards

You just have to specify some condition and return the list in py file

@frappe.whitelist(allow_guest=True)
def get_details_based_permission(user):
dep_list = “(tabDepartment.status <> ‘final approval’ )”
return dep_list

and in hooks.py, specify path to above method

permission_query_conditions = {
“doctype name” : Appname.Appname.doctype.docname.docname.get_details_based_permission
}

thnx a lot
i will applay and feedback