Workflow with user based listview

Hi,

I have created submittable doctype which flows with 5 stages of approval I have successfully completed the flow with 4 roles.

But currently user insist to have the list view based on the user based i.e User able to view the doctype which created by him once submitted doctype need to get assigned to the certain user based on the condition i.e, approver then he only gets to see the doctype likewise it’s need to flow.

Please let me know whether it is possible to assign the doctype to the user of the next workflow without compromising the flow and user based view.

Thks in advance.

Regards,
Balram Singh

Only possible with the filters

I have already created the listview but it is not successful I want the guidance how to assign the doctype to the user with the role and filter accordingly.

Code I have created:

frappe.listview_settings['Proposed Branch Details'] = {
    onload: function(listview) {
        if (frappe.user.has_role('Branch Initiator')) {
            frappe.route_options = {
                "workflow_state": ["=", "Draft"]
            };
            $('.filter-selector').hide();
        } else if (frappe.user.has_role('Branch Responsible Person')) {
            frappe.route_options = {
                "workflow_state": ["=", "Assigned to the Responsible Person"]
            };
            $('.filter-selector').hide();
        } else if (frappe.user.has_role('RB Manager')) {
            frappe.route_options = {
                "workflow_state": ["=", "Approval pending with RB Manager"]
            };
            $('.filter-selector').hide();
        } else if (frappe.user.has_role('Approval Manager')) {
            frappe.route_options = {
                "workflow_state": ["=", "Approval pending with Approval Manager"]
            };
            $('.filter-selector').hide();
        } 
    }

};

but it is not allowing the allowing the admin to view the entire list eventhough I didnt assign the any role mentioned above to the admin if I check using the frappe.user.has_role(‘Branch Initiator’) it says true could u pls let me know how to avoid this…

Can we do it with permission_query_conditions() . Couldn’t see any useful documentation about it