From 92b184bc2240bb02afd93d2cadc63930e170cf27 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Fri, 10 Oct 2025 18:26:21 +0530 Subject: [PATCH 1/4] Create test.js --- Specialized Areas/Fix scripts/test.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 Specialized Areas/Fix scripts/test.js diff --git a/Specialized Areas/Fix scripts/test.js b/Specialized Areas/Fix scripts/test.js new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/Specialized Areas/Fix scripts/test.js @@ -0,0 +1 @@ + From f0add90e292d47924110b758d3e0a1c123b4abb5 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Fri, 10 Oct 2025 18:27:02 +0530 Subject: [PATCH 2/4] Delete Specialized Areas/Fix scripts/test.js --- Specialized Areas/Fix scripts/test.js | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Specialized Areas/Fix scripts/test.js diff --git a/Specialized Areas/Fix scripts/test.js b/Specialized Areas/Fix scripts/test.js deleted file mode 100644 index 8b13789179..0000000000 --- a/Specialized Areas/Fix scripts/test.js +++ /dev/null @@ -1 +0,0 @@ - From a018e1504c2c1f366814725d4acbfc58ee2a5c3d Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Tue, 14 Oct 2025 20:14:44 +0530 Subject: [PATCH 3/4] Create script.js --- .../script.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Health Scan Prevent Insert Update in Before BRs/script.js diff --git a/Client-Side Components/Client Scripts/Health Scan Prevent Insert Update in Before BRs/script.js b/Client-Side Components/Client Scripts/Health Scan Prevent Insert Update in Before BRs/script.js new file mode 100644 index 0000000000..78fa387872 --- /dev/null +++ b/Client-Side Components/Client Scripts/Health Scan Prevent Insert Update in Before BRs/script.js @@ -0,0 +1,15 @@ +function onSubmit() { + /* + This client script will prevent insert and update operation in onBefore business rules. + Table: sys_script + Type: onSubmit + Ui Type: Desktop + */ + var whenCond = g_form.getValue('when'); // when condition of business rule + var scriptVal = g_form.getValue('script'); // script value of business rule. + + if (whenCond == 'before' && (scriptVal.indexOf('insert()') > -1 || scriptVal.indexOf('update()')) > -1) { + alert("As per ServiceNow best Practise insert and update should be avoided in onBefore BRs. If you still want tp proceed try deactivating client script : " + g_form.getUniqueValue()); + return false; + } +} From 3c5609b8426f06bcc964ae7f011b98450f646e37 Mon Sep 17 00:00:00 2001 From: Raghav Sharma <53517312+raghavs046@users.noreply.github.com> Date: Tue, 14 Oct 2025 20:19:21 +0530 Subject: [PATCH 4/4] Create README.md --- .../README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Client-Side Components/Client Scripts/Health Scan Prevent Insert Update in Before BRs/README.md diff --git a/Client-Side Components/Client Scripts/Health Scan Prevent Insert Update in Before BRs/README.md b/Client-Side Components/Client Scripts/Health Scan Prevent Insert Update in Before BRs/README.md new file mode 100644 index 0000000000..0eab8c5369 --- /dev/null +++ b/Client-Side Components/Client Scripts/Health Scan Prevent Insert Update in Before BRs/README.md @@ -0,0 +1,11 @@ +**Client script Deatils** +1. Table: sys_script +2. Type: onSubmit +3. UI Type: Desktop + +**Benefits** +1. This client script will prevent admin users to do insert/update operation in onBefore business rules. +2. It will help to avoid HealthScan findings thus increasing healthscan score. +3. Will prevent recursive calls. + +Link to ServiceNow Business Rules best Practise : https://developer.servicenow.com/dev.do#!/guide/orlando/now-platform/tpb-guide/business_rules_technical_best_practices