Skip to content

Commit bd6c8e6

Browse files
committed
feat: Add Business Rule snippet for close code validation
1 parent 714032d commit bd6c8e6

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Prevent Incident Closure Without a Close Code
2+
3+
This snippet is for a **'before' Business Rule** that prevents a user from closing an incident if the 'Close Code' field is empty. It displays an error message and aborts the update.
4+
5+
## How to Use
6+
7+
1. **Table:** `incident`
8+
2. **When:** `before`
9+
3. **Actions:** Check `update`
10+
4. **Condition (Filter):**
11+
* `State | changes to | Closed`
12+
* *(Note: 'Closed' is often value 7, but check your instance)*
13+
5. **Advanced Tab:**
14+
* Check the `Advanced` box.
15+
* Paste the code from `prevent_closure.js` into the script field.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(function executeRule(current, previous /*, gs, sup*/) {
2+
3+
// Check if the close_code field is empty or null
4+
// You can add other fields to this check, e.g., || gs.nil(current.close_notes)
5+
if (gs.nil(current.close_code)) {
6+
7+
// Display an error message at the top of the form
8+
gs.addErrorMessage('A Close Code is required before closing an incident.');
9+
10+
// Stop the database action (update) from happening
11+
current.setAbortAction(true);
12+
}
13+
14+
})(current, previous);

0 commit comments

Comments
 (0)