Skip to content

Commit 0af7289

Browse files
authored
Add Business Rule: Enhance Incident Description with Linked Problem Statement (#1776)
* Add Business Rule: Enhance Incident Description with Linked Problem Statement * Add README for Enhance Incident with Linked Problem Business Rule
1 parent f609e38 commit 0af7289

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function executeRule(current, previous /*null when async*/) {
2+
try {
3+
// Check if problem_id was added or changed
4+
var isNewLink = !previous || current.problem_id.changes();
5+
6+
if (isNewLink && current.problem_id) {
7+
var problemGR = new GlideRecord("problem");
8+
9+
if (problemGR.get(current.problem_id)) {
10+
var problemStatement = problemGR.short_description;
11+
var problemNumber = problemGR.number;
12+
13+
// Append to description
14+
current.description = (current.description || '') +
15+
"\n\n[Linked Problem] " + problemNumber + ": " + problemStatement;
16+
}
17+
}
18+
} catch (ex) {
19+
gs.error("An unexpected error occurred while enhancing the Incident with Problem details.");
20+
}
21+
})(current, previous);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Enhance Incident Description with Linked Problem Statement
2+
3+
## Overview
4+
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.
5+
6+
## Features
7+
- Triggered when a Problem ID is newly linked or changed on an Incident.
8+
- Fetches the Problem's short description and number.
9+
- Appends the Problem Statement to both the Incident's short description and description fields.
10+
- Includes general error handling to ensure stability.
11+
12+
## Business Rule Configuration
13+
- Table: `incident`
14+
- When to Run: `before insert` and `before update`
15+
- Condition:
16+
```javascript
17+
current.problem_id.changes() || !previous

0 commit comments

Comments
 (0)