Skip to content

Commit 7517a37

Browse files
authored
Prevent Recursive Updates From Integrations (#2026)
* Create prevent_continous_update.js BR Code * Create README.md
1 parent 2914895 commit 7517a37

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
**Business Rule**
2+
3+
Table : Any Custom Table or (Incident,Problem , Change)...
4+
Active : true
5+
When : before
6+
Update : true
7+
order : 100
8+
9+
condition : gs.getUser().getUserName() == 'integration.user/Web services User'
10+
11+
The rule must only run when the update is coming from the dedicated integration user to avoid impacting manual user updates, Can Update Fields to check as Required
12+
13+
This business rule is designed to prevent unnecessary and redundant updates to records that are synchronized with external systems (e.g., Jira, Azure DevOps, or a custom application) via integration / E bonding
14+
15+
This rule executes a check to ensure that the fields critical to the integration (Work Notes, Comments, State) have genuinely changed before allowing the update to process.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(function executeRule(current, previous) {
2+
3+
if (current.isNewRecord() || !current.isValidRecord() || current.operation() == 'delete') {
4+
return;
5+
}
6+
var fieldsToCheck = ['work_notes', 'comments', 'state'];
7+
var allFieldsSame = true;
8+
for (var i = 0; i < fieldsToCheck.length; i++) {
9+
var field = fieldsToCheck[i];
10+
if (current.changes.call(current, field) && current[field].toString() !== previous[field].toString()) {
11+
allFieldsSame = false;
12+
break;
13+
}
14+
}
15+
if (allFieldsSame) {
16+
gs.info('BR skipped redundant integration update for ' + current.sys_class_name + ': ' + current.number);
17+
current.setAbortAction(true);
18+
}
19+
20+
})(current, previous);

0 commit comments

Comments
 (0)