From 351b0dec66d56744a67cf2832a8eeea808f9b697 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 9 Feb 2018 14:21:02 +0100 Subject: [PATCH] Fixed issue #1813 - JS error on creating new customer. --- .../lib/app_post/user_organization_autocompletion.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.coffee b/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.coffee index 28fffcfdf..ca9578fba 100644 --- a/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.coffee +++ b/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.coffee @@ -37,8 +37,11 @@ class UserNew extends App.ControllerModal # find role_id if !params.role_ids || _.isEmpty(params.role_ids) - role = App.Role.findByAttribute('name', 'Customer') - params.role_ids = role.id + role_ids = [] + for role of App.Role.all() + if role && role.active is true && role.default_at_signup is true + role_ids.push role.id + params.role_ids = role_ids @log 'notice', 'updateAttributes', params user = new App.User