Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Table: Incident
When to run : On Before Insert

Use case:

This Business rule prevents users from creating duplicate incidents. Its checks last 7 days open incident with same caller and short description.
When a user tries to create an incident with the same short description and caller, the system:
Stops the new record from being created.
Displays an info message with a clickable link to the existing incident.

This helps reduce incident clutter and ensures users track existing issues instead of repeatedly logging new ones.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(function executeRule(current, previous /*null when async*/) {
var dup = new GlideRecord('incident');
dup.addQuery('caller_id', current.caller_id);
dup.addQuery('short_description', current.short_description);
dup.addQuery('state', '!=', 6); // Exclude closed
var sevenDaysAgo = new GlideDateTime();
sevenDaysAgo.addDaysUTC(-7);
dup.addQuery('sys_created_on', '>=', sevenDaysAgo);
dup.query();

if (dup.next()) {
// Build URL dynamically based on instance name
var instanceName = gs.getProperty('instance_name');
var url = gs.getProperty('glide.servlet.uri') + 'incident.do?sys_id=' + dup.sys_id;

// Add info message with hyperlink
gs.addInfoMessage("A similar incident <a target='_blank' href='" + url + "'>" + dup.number + "</a> already exists (created within the last 7 days).");

// Stop creation of duplicate
current.setAbortAction(true);
}
})(current, previous);
Loading