Bypass Listview for Employee role

Hello,

For employee role, if any employee opens employee doctype then it shows them only their name in listview and then the detailed form.

What I want is for employee roles only, if they open employee doctype, it redirects/routes them to the details page, bypassing the listview. Is there any client script? I was using the below script and it redirects them but getting the error “undefined” for roles other than the employee for eg. Admin and HR

And also if I click back then also it is continuously redirecting me to the same page.

Thanks.

frappe.listview_settings['Employee'] = {
  get_form_link: function(doc) {
    if(frappe.user.has_role(['Employee']))
    {
        frappe.set_route("/app/employee/" + doc.name);
    }
  }
}