diff --git a/Business Rules/Notification/Send Notification on New Incident Creation.js b/Business Rules/Notification/Send Notification on New Incident Creation.js new file mode 100644 index 0000000000..8954ea10d3 --- /dev/null +++ b/Business Rules/Notification/Send Notification on New Incident Creation.js @@ -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); diff --git a/Business Rules/Notification/readme.md b/Business Rules/Notification/readme.md new file mode 100644 index 0000000000..ac6575d4d6 --- /dev/null +++ b/Business Rules/Notification/readme.md @@ -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.