From ded5d1626dc062bc1156c8f4ee98f7ffbb92a934 Mon Sep 17 00:00:00 2001 From: Indra-kolge <123245160+Indra-kolge@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:40:06 +0530 Subject: [PATCH 1/2] script.js --- .../script.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Server-Side Components/Business Rules/Updated Needs attention checkbox bases on condition/script.js diff --git a/Server-Side Components/Business Rules/Updated Needs attention checkbox bases on condition/script.js b/Server-Side Components/Business Rules/Updated Needs attention checkbox bases on condition/script.js new file mode 100644 index 0000000000..f2d2aea62f --- /dev/null +++ b/Server-Side Components/Business Rules/Updated Needs attention checkbox bases on condition/script.js @@ -0,0 +1,35 @@ +if (current.assigned_to && current.sys_updated_by != 'system') { + var assigned = current.assigned_to.toString(); + var updated = current.sys_updated_by; + var needsAtt = current.needs_attention; + + var roles = [ + 'sn_customerservice.customer', + 'sn_customerservice.customer_contact' + ]; + + // Check if updated user has any required role + var hasRole = false; + if (updated) { + for (var i = 0; i < roles.length; i++) { + var roleName = roles[i]; + var roleGr = new GlideRecord('sys_user_role'); + if (roleGr.get('name', roleName)) { + var userRoleGr = new GlideRecord('sys_user_has_role'); + userRoleGr.addQuery('user', updated); + userRoleGr.addQuery('role', roleGr.sys_id); + userRoleGr.query(); + if (userRoleGr.next()) { + hasRole = true; + break; + } + } + } + } + + if (assigned != updated && hasRole) { + current.needs_attention = true; + } else if (assigned == updated && needsAtt == true) { + current.needs_attention = false; + } +} From a3bb942f97c02d848c2026057660d85b5d22f62d Mon Sep 17 00:00:00 2001 From: Indra-kolge <123245160+Indra-kolge@users.noreply.github.com> Date: Sat, 18 Oct 2025 14:41:33 +0530 Subject: [PATCH 2/2] README.md --- .../README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Server-Side Components/Business Rules/Updated Needs attention checkbox bases on condition/README.md diff --git a/Server-Side Components/Business Rules/Updated Needs attention checkbox bases on condition/README.md b/Server-Side Components/Business Rules/Updated Needs attention checkbox bases on condition/README.md new file mode 100644 index 0000000000..c294e0e4ad --- /dev/null +++ b/Server-Side Components/Business Rules/Updated Needs attention checkbox bases on condition/README.md @@ -0,0 +1,12 @@ +Table: sn_customerservice_case +When to run: Before update +condition : additional comment changes + +Use case: + +When a user adds additional comments on a case, the system needs to determine if the case requires further attention from the assigned user. +This determination depends on who updated the case and their roles. +If the update is made by an automated system user (sys_updated_by == 'system'), no action is taken. +If the update is made by a user who holds one of the specified roles (e.g., customer service roles or fulfillers), and this user is not the current assigned user, then the case should be flagged as needing attention (needs_attention = true). +If the update is made by the currently assigned user, and needs_attention was previously set to true, it should now be cleared (needs_attention = false) because the assigned user has presumably addressed the issue. +This ensures that when others contribute to the case, the assigned user knows to review it, but when the assigned user updates the case, the attention flag is cleared.