Skip to content
Merged
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,21 @@
(function executeRule(current, previous /*null when async*/) {

// Only run for active incidents
if (!current.caller_id || !current.short_description)
return;

// Create a GlideRecord on the incident table
var gr = new GlideRecord('incident');
gr.addQuery('caller_id', current.caller_id); // Same caller
gr.addQuery('short_description', current.short_description); // Same issue text
gr.addQuery('sys_created_on', '>=', gs.hoursAgoStart(24)); // Within last 24 hours
gr.addQuery('state', '!=', 7); // Exclude closed incidents
gr.query();

if (gr.next()) {
// Stop insert and show an error
gs.addErrorMessage("A similar incident has already been raised within the last 24 hours: " + gr.number);
current.setAbortAction(true); // Prevent record creation
}

})(current, previous);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Prevent Duplicate Incident Creation within 24 Hours

1. Write a Business Rule - Before Insert
2. Select the Incident Table
3. Only run/execute for all the active incidents
4. By Gliding the Incident Table will get the caller_id, short_description for checking the current caller and text provided for the short description
5. Querying the Incident Table as created within 24 Hours and excluding the closed incidents
6. Stop insert and show an error message
7. Prevent Incident record creation
Loading