From e4dcd1122e0122990f706d43e23d3628876cf493 Mon Sep 17 00:00:00 2001 From: Harshal Patel <100208298+harshal045@users.noreply.github.com> Date: Sat, 4 Oct 2025 19:51:25 +0530 Subject: [PATCH 1/2] Add Business Rule: Enhance Incident Description with Linked Problem Statement --- .../EnhanceIncidentWithProblem.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Server-Side Components/Business Rules/EnhanceIncidentWithProblem/EnhanceIncidentWithProblem.js diff --git a/Server-Side Components/Business Rules/EnhanceIncidentWithProblem/EnhanceIncidentWithProblem.js b/Server-Side Components/Business Rules/EnhanceIncidentWithProblem/EnhanceIncidentWithProblem.js new file mode 100644 index 0000000000..db9bcfbb8b --- /dev/null +++ b/Server-Side Components/Business Rules/EnhanceIncidentWithProblem/EnhanceIncidentWithProblem.js @@ -0,0 +1,21 @@ +function executeRule(current, previous /*null when async*/) { + try { + // Check if problem_id was added or changed + var isNewLink = !previous || current.problem_id.changes(); + + if (isNewLink && current.problem_id) { + var problemGR = new GlideRecord("problem"); + + if (problemGR.get(current.problem_id)) { + var problemStatement = problemGR.short_description; + var problemNumber = problemGR.number; + + // Append to description + current.description = (current.description || '') + + "\n\n[Linked Problem] " + problemNumber + ": " + problemStatement; + } + } + } catch (ex) { + gs.error("An unexpected error occurred while enhancing the Incident with Problem details."); + } +})(current, previous); From a676645802665d1dd35cf31989d5fc35a396667b Mon Sep 17 00:00:00 2001 From: Harshal Patel <100208298+harshal045@users.noreply.github.com> Date: Sat, 4 Oct 2025 20:55:34 +0530 Subject: [PATCH 2/2] Add README for Enhance Incident with Linked Problem Business Rule --- .../EnhanceIncidentWithProblem/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Server-Side Components/Business Rules/EnhanceIncidentWithProblem/README.md diff --git a/Server-Side Components/Business Rules/EnhanceIncidentWithProblem/README.md b/Server-Side Components/Business Rules/EnhanceIncidentWithProblem/README.md new file mode 100644 index 0000000000..9c0d01039d --- /dev/null +++ b/Server-Side Components/Business Rules/EnhanceIncidentWithProblem/README.md @@ -0,0 +1,17 @@ +# Enhance Incident Description with Linked Problem Statement + +## Overview +This ServiceNow Business Rule enhances Incident records by automatically appending the short description of a linked Problem record. It improves visibility and context for support teams working on related incidents. + +## Features +- Triggered when a Problem ID is newly linked or changed on an Incident. +- Fetches the Problem's short description and number. +- Appends the Problem Statement to both the Incident's short description and description fields. +- Includes general error handling to ensure stability. + +## Business Rule Configuration +- Table: `incident` +- When to Run: `before insert` and `before update` +- Condition: + ```javascript + current.problem_id.changes() || !previous