diff --git a/Business Rules/AutoAssignment/Auto Assign Incident.js b/Business Rules/AutoAssignment/Auto Assign Incident.js new file mode 100644 index 0000000000..3b6dc63432 --- /dev/null +++ b/Business Rules/AutoAssignment/Auto Assign Incident.js @@ -0,0 +1,12 @@ +// Business Rule: Auto Assign Incident +// When: Before Insert & Table: Incident +(function executeRule(current, previous /*null when async*/) { + if (current.assigned_to.nil()) { + var group = new GlideRecord('sys_user_group'); + group.addQuery('name', 'IT Support'); + group.query(); + if (group.next()) { + current.assigned_to = group.getValue('manager'); + } + } +})(current, previous); diff --git a/Business Rules/AutoAssignment/readme.md b/Business Rules/AutoAssignment/readme.md new file mode 100644 index 0000000000..a888820f52 --- /dev/null +++ b/Business Rules/AutoAssignment/readme.md @@ -0,0 +1,3 @@ +This Business Rule runs before an incident is inserted. +If no user is assigned, it looks up the "IT Support" group and assigns the incident to the group's manager. +This ensures that incidents are promptly directed to the appropriate personnel. 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.