From 68697eb1472d1c3879aca13d714d6eb8f2bfa0ac Mon Sep 17 00:00:00 2001 From: Shakeel Shaik <72960980+am-shakeel@users.noreply.github.com> Date: Tue, 29 Oct 2024 05:53:13 +0530 Subject: [PATCH] =?UTF-8?q?Revert=20"Send=20notification=20if=20the=20inci?= =?UTF-8?q?dent=20remains=20unassigned=20for=20more=20than=205=20=E2=80=A6?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 2eef425263e4fe3f89a2f71f599017187eb4f2e6. --- .../readme.md | 16 -------- .../script.js | 40 ------------------- 2 files changed, 56 deletions(-) delete mode 100644 UI Actions/Send notification if the incident remains unassigned/readme.md delete mode 100644 UI Actions/Send notification if the incident remains unassigned/script.js diff --git a/UI Actions/Send notification if the incident remains unassigned/readme.md b/UI Actions/Send notification if the incident remains unassigned/readme.md deleted file mode 100644 index 2ec7561cce..0000000000 --- a/UI Actions/Send notification if the incident remains unassigned/readme.md +++ /dev/null @@ -1,16 +0,0 @@ -This is a UI Action script that adds a button to the Incident form. When clicked, it will check if the incident has been unassigned for more than 5 days. -If this condition is met, the button will trigger a notification to the manager of the incident's assignment group, informing them that the incident is still unassigned. - -Below are the conditions when UI action will be created: -Table: Incident -Show Insert: False -Show Update: True -Form Button: Checked (to add the button on the form) -Condition: current.assigned_to.nil() && current.assignment_group - -The code contains below vaidations: -- The script checks if the incident has been unassigned for more than 5 days by comparing the current date with the sys_created_on date using gs.daysAgo(). -- It verifies that the incident has an assignment group. If it does not, it displays an error message. -- Queries the sys_user_group table to get the assignment group’s manager. If a manager is found, it sets up a notification to send an email directly to the manager. -- Provides feedback to the user if the notification was sent or if there were issues (like missing assignment group or manager). -- Redirects the user back to the current incident form after the UI Action runs. diff --git a/UI Actions/Send notification if the incident remains unassigned/script.js b/UI Actions/Send notification if the incident remains unassigned/script.js deleted file mode 100644 index d3700db022..0000000000 --- a/UI Actions/Send notification if the incident remains unassigned/script.js +++ /dev/null @@ -1,40 +0,0 @@ -// Check if the incident has been unassigned for more than 5 days -var unassignedDuration = gs.daysAgo(current.sys_created_on); -if (unassignedDuration < 5) { - gs.addErrorMessage("The incident has been unassigned for less than 5 days."); - action.setRedirectURL(current); - return; -} - -// Check if the incident has an assignment group -if (current.assignment_group.nil()) { - gs.addErrorMessage("No assignment group is set for this incident."); - action.setRedirectURL(current); - return; -} - -// Get the assignment group's manager -var assignmentGroup = new GlideRecord('sys_user_group'); -if (assignmentGroup.get(current.assignment_group)) { - var manager = assignmentGroup.getValue('manager'); - - if (manager) { - // Create a notification - var notification = new GlideEmailOutbound(); - notification.setFrom('no-reply@xyz.com'); - notification.setSubject("Alert! Incident " + current.number + " is still unassigned"); - notification.setBody("The incident " + current.number + " has been unassigned for more than 5 days. Please assign it promptly."); - notification.setTo(manager); - - // Send the email - notification.send(); - - gs.addInfoMessage("Notification sent to the assignment group's manager."); - } else { - gs.addErrorMessage("The assignment group has no manager defined."); - } -} else { - gs.addErrorMessage("Could not find the assignment group."); -} - -action.setRedirectURL(current);