Skip to content

Commit 932e34a

Browse files
authored
Create README.md
1 parent 0b16110 commit 932e34a

File tree

1 file changed

+35
-0
lines changed
  • Core ServiceNow APIs/GlideElement/Smart Field Validation and Dependent Field Derivation Using getError() and setError()

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Smart Field Validation and Dependent Field Derivation Using GlideElement.getError()
2+
3+
This project demonstrates how to use `GlideElement.setError()` and `GlideElement.getError()`
4+
to perform validation in one Business Rule and field derivation in another, without repeating logic.
5+
6+
## 📘 Overview
7+
8+
This snippet demonstrates how to share validation state and error messages between multiple Business Rules using `GlideElement.setError()` and `GlideElement.getError()` in ServiceNow.
9+
10+
By propagating validation context across Business Rules, developers can:
11+
12+
- Avoid repeated validation logic.
13+
- Trigger dependent field updates only when a field passes validation.
14+
- Maintain consistent and clean data flow between sequential rules.
15+
16+
This technique is especially useful when different validation or derivation rules are split by purpose or owned by different teams.
17+
18+
---
19+
20+
## 🧠 Concept
21+
22+
When one Business Rule sets an error on a field using `setError()`, the error message persists in memory for that record during the same transaction.
23+
A later Business Rule (executing at a higher order) can then retrieve that message using `getError()` and make data-driven decisions.
24+
25+
### Flow:
26+
1. BR #1 (`Validate Short Description`) checks text length.
27+
2. BR #2 (`Derive Dependent Fields`) runs only if no validation error exists.
28+
3. Category, Subcategory, and Impact are derived dynamically.
29+
30+
## 🚀 Benefits
31+
32+
- ✅ Reduces redundant validation checks
33+
- ✅ Improves rule execution efficiency
34+
- ✅ Keeps logic modular and maintainable
35+
- ✅ Provides better visibility and control in field validations

0 commit comments

Comments
 (0)