From c3779851e493344556220c8ed9e37ad2d27d67ca Mon Sep 17 00:00:00 2001 From: Karthikeyan S Date: Wed, 15 May 2019 11:38:20 +0530 Subject: [PATCH] fix(HR Settings): Unable to save HR Settings (#17608) --- erpnext/hr/doctype/hr_settings/hr_settings.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/hr/doctype/hr_settings/hr_settings.js b/erpnext/hr/doctype/hr_settings/hr_settings.js index 58ce4226e9..d8be46bee7 100644 --- a/erpnext/hr/doctype/hr_settings/hr_settings.js +++ b/erpnext/hr/doctype/hr_settings/hr_settings.js @@ -13,9 +13,11 @@ frappe.ui.form.on('HR Settings', { validate: function(frm) { let policy = frm.doc.password_policy; - if (policy.includes(' ') || policy.includes('--')) { - frappe.msgprint("Password policy cannot contain spaces or simultaneous hyphens. The format will be restructured automatically"); + if (policy) { + if (policy.includes(' ') || policy.includes('--')) { + frappe.msgprint("Password policy cannot contain spaces or simultaneous hyphens. The format will be restructured automatically"); + } + frm.set_value('password_policy', policy.split(new RegExp(" |-", 'g')).filter((token) => token).join('-')); } - frm.set_value('password_policy', policy.split(new RegExp(" |-", 'g')).filter((token) => token).join('-')); } });