Skip to content

Send notification on incident creation #1101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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,13 @@
// Business Rule: Send Notification on New Incident Creation
// When: After Insert and Table: Incident
(function executeRule(current, previous /*null when async*/) {
// Only send notification for newly created incidents
if (current.isNewRecord()) {
var gr = new GlideRecord('sys_user');
gr.get(current.assigned_to);
// Prepare the notification message
var message = 'A new incident has been assigned to you: ' + current.number;
// Send the notification
gs.eventQueue('incident.new', current, gr.sys_id, message);
}
})(current, previous);
5 changes: 5 additions & 0 deletions Business Rules/Notification/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Trigger: This business rule runs after a new incident is inserted into the Incident table.
Check: It checks if the record is new using current.isNewRecord().
User Lookup: It retrieves the assigned user’s record using GlideRecord.
Message Preparation: It constructs a message indicating a new incident has been assigned.
Event Queue: Finally, it uses gs.eventQueue to send the notification event.
Loading