diff --git a/Server-Side Components/Business Rules/Preventing Recursive Updates from Integrations/README.md b/Server-Side Components/Business Rules/Preventing Recursive Updates from Integrations/README.md new file mode 100644 index 0000000000..f751eb2a9f --- /dev/null +++ b/Server-Side Components/Business Rules/Preventing Recursive Updates from Integrations/README.md @@ -0,0 +1,15 @@ +**Business Rule** + +Table : Any Custom Table or (Incident,Problem , Change)... +Active : true +When : before +Update : true +order : 100 + +condition : gs.getUser().getUserName() == 'integration.user/Web services User' + +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 + +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 + +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. diff --git a/Server-Side Components/Business Rules/Preventing Recursive Updates from Integrations/prevent_continous_update.js b/Server-Side Components/Business Rules/Preventing Recursive Updates from Integrations/prevent_continous_update.js new file mode 100644 index 0000000000..590c3c49da --- /dev/null +++ b/Server-Side Components/Business Rules/Preventing Recursive Updates from Integrations/prevent_continous_update.js @@ -0,0 +1,20 @@ +(function executeRule(current, previous) { + + if (current.isNewRecord() || !current.isValidRecord() || current.operation() == 'delete') { + return; + } + var fieldsToCheck = ['work_notes', 'comments', 'state']; + var allFieldsSame = true; + for (var i = 0; i < fieldsToCheck.length; i++) { + var field = fieldsToCheck[i]; + if (current.changes.call(current, field) && current[field].toString() !== previous[field].toString()) { + allFieldsSame = false; + break; + } + } + if (allFieldsSame) { + gs.info('BR skipped redundant integration update for ' + current.sys_class_name + ': ' + current.number); + current.setAbortAction(true); + } + +})(current, previous);