Skip to content
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,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.
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading