From a138519728e7ecc295b32931528b6e3bd919e8d0 Mon Sep 17 00:00:00 2001 From: Code with bhav <92107107+bhavyaa30@users.noreply.github.com> Date: Sun, 5 Oct 2025 18:09:21 +0530 Subject: [PATCH 1/3] script.js --- .../Prevent Invalid Field Combinations/script.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Server-Side Components/Business Rules/Prevent Invalid Field Combinations/script.js diff --git a/Server-Side Components/Business Rules/Prevent Invalid Field Combinations/script.js b/Server-Side Components/Business Rules/Prevent Invalid Field Combinations/script.js new file mode 100644 index 0000000000..9108ab1735 --- /dev/null +++ b/Server-Side Components/Business Rules/Prevent Invalid Field Combinations/script.js @@ -0,0 +1,9 @@ +(function executeRule(current, previous /*null when async*/) { + + // Example: Prevent record submission if Impact = Low and Priority = High + if (current.impact == 3 && current.priority == 1) { // 3 = Low, 1 = High + gs.addErrorMessage("Invalid combination: 'High' Priority cannot be set with 'Low' Impact."); + current.setAbortAction(true); // Prevents insert/update + } + +})(current, previous); From 6da9c6c1cd4797cff3414f9fba62fdda21699fed Mon Sep 17 00:00:00 2001 From: Code with bhav <92107107+bhavyaa30@users.noreply.github.com> Date: Sun, 5 Oct 2025 18:10:28 +0530 Subject: [PATCH 2/3] readme.md --- .../Prevent Invalid Field Combinations/readme.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Server-Side Components/Business Rules/Prevent Invalid Field Combinations/readme.md diff --git a/Server-Side Components/Business Rules/Prevent Invalid Field Combinations/readme.md b/Server-Side Components/Business Rules/Prevent Invalid Field Combinations/readme.md new file mode 100644 index 0000000000..5af0e68805 --- /dev/null +++ b/Server-Side Components/Business Rules/Prevent Invalid Field Combinations/readme.md @@ -0,0 +1,5 @@ +In IT Service Management (ITSM), certain field combinations don’t make sense logically — for instance: +A High Priority incident should not have a Low Impact. +A Change Request marked as Emergency should not have Approval Type = Standard. +ServiceNow’s out-of-the-box (OOB) configurations can validate simple field requirements, but cannot enforce relational validation between two or more fields at the server-side level. +This custom Business Rule ensures data integrity by preventing users from saving or updating records when invalid field combinations occur. From be4a915e3a438b6c9a1081c56fb0a89b54d9aa13 Mon Sep 17 00:00:00 2001 From: Code with bhav <92107107+bhavyaa30@users.noreply.github.com> Date: Sun, 5 Oct 2025 18:50:01 +0530 Subject: [PATCH 3/3] Update readme.md --- .../Prevent Invalid Field Combinations/readme.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Server-Side Components/Business Rules/Prevent Invalid Field Combinations/readme.md b/Server-Side Components/Business Rules/Prevent Invalid Field Combinations/readme.md index 5af0e68805..a4472f5867 100644 --- a/Server-Side Components/Business Rules/Prevent Invalid Field Combinations/readme.md +++ b/Server-Side Components/Business Rules/Prevent Invalid Field Combinations/readme.md @@ -3,3 +3,14 @@ A High Priority incident should not have a Low Impact. A Change Request marked as Emergency should not have Approval Type = Standard. ServiceNow’s out-of-the-box (OOB) configurations can validate simple field requirements, but cannot enforce relational validation between two or more fields at the server-side level. This custom Business Rule ensures data integrity by preventing users from saving or updating records when invalid field combinations occur. + +Details of Implementation +Created a new Business Rule: Prevent Invalid Field Combinations +Table: incident +Advanced: ✅ Checked +When to run: Before Insert & Before Update +Filter condition (optional): Leave blank or specify field conditions where you want this rule to apply +Script logic: +Checks if Impact = 3 (Low) and Priority = 1 (High). +Displays a user-friendly error message. +Aborts record submission to maintain data integrity.