diff --git a/e2e/paths/client-module/02_edit_basic_data.spec.js b/e2e/paths/client-module/02_edit_basic_data.spec.js index ea58176cf5..671f64fd0c 100644 --- a/e2e/paths/client-module/02_edit_basic_data.spec.js +++ b/e2e/paths/client-module/02_edit_basic_data.spec.js @@ -116,7 +116,7 @@ describe('Edit basicData path', () => { return nightmare .getInputValue(selectors.clientBasicData.salesPersonInput) .then(result => { - expect(result).toEqual('accessory accessory'); + expect(result).toEqual('accessory'); }); }); diff --git a/services/loopback/common/methods/client/activeSalesPerson.js b/services/loopback/common/methods/client/activeSalesPerson.js index 53e1769cbc..b5baa072f2 100644 --- a/services/loopback/common/methods/client/activeSalesPerson.js +++ b/services/loopback/common/methods/client/activeSalesPerson.js @@ -27,10 +27,16 @@ module.exports = Self => { let params = []; if (where) { - sqlWhere = `AND (em.firstName REGEXP ? OR em.name REGEXP ?)`; - let search = where.firstName.regexp; - params.push(search); - params.push(search); + if (where.firstName) { + sqlWhere = `AND (em.firstName REGEXP ? OR em.name REGEXP ?)`; + let search = where.firstName.regexp; + params.push(search); + params.push(search); + } + if (where.id) { + sqlWhere = `AND em.id = ?`; + params.push(where.id); + } } if (filter.limit) { sqlLimit = `LIMIT ?`;