@mention Groups in Work Notes

tiguin2798
Tera Guru

Team, I am new to ServiceNow and it has been requested to add @mentions for groups to be tagged in work notes and additional comments as users can. Is there a way to add in this function as the most recent response I am finding is from 2020 where this was not possible. This was a highly used function in our previous ticketing system we would like to retain.

We are on the Utah release and I see that this was to be implemented with New York.

https://www.servicenow.com/community/developer-forum/mentions-groups/m-p/1413135

2 REPLIES 2

Allen Andreas
Administrator
Administrator

Hi,

Unfortunately, this still doesn't appear to be supported by the platform. I'm unsure where the other poster got the information from that in New York this would be added. I can't find anything about it being added and in a fresh Vancouver instance, I can't mention groups.

 

With that said, it does look like there's a possibility to add this functionality without too much effort. Perhaps review this post here and consider implementing the same. Essentially, you can have your users use @group and then the group name and in a business rule, work to trigger the mention with the sys_id of the group maybe?

https://www.servicenow.com/community/developer-forum/how-to-tag-an-assignment-group-on-work-note/m-p... 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

MakhanlalM
Tera Contributor

Business rules 

Table name : sys_journal_field 

after or async

(function executeRule(current, previous /* null when async */) {
// Get the comment text where the user may have tagged a group using @ACRONYM
var commentText = current.value;

// Look for a pattern like "@ABC" (an @ sign followed by letters)
var acronymMatch = /@([A-Z]+)/i.exec(commentText);
if (!acronymMatch || acronymMatch.length < 2) {
// No acronym tag found, so just exit
return;
}

// Extract the acronym and convert it to uppercase to standardize
var acronym = acronymMatch[1].toUpperCase();

// Find the user group whose name matches the acronym exactly
var groupRecord = new GlideRecord('sys_user_group');
groupRecord.addQuery('name', acronym);
groupRecord.query();
if (!groupRecord.next()) {
// No group found with that name; exit
return;
}

// Find all members of the group
var groupMembers = new GlideRecord('sys_user_grmember');
groupMembers.addQuery('group', groupRecord.sys_id);
groupMembers.query();

// Collect all user sys_ids of group members
var userIds = [];
while (groupMembers.next()) {
userIds.push(groupMembers.user.toString());
}

// If no users found in the group, exit
if (userIds.length === 0) {
return;
}

// Get the incident record related to this current record (based on element_id)
var incidentSysId = current.element_id;
if (!incidentSysId) {
return;
}

var incidentRecord = new GlideRecord('incident');
if (!incidentRecord.get(incidentSysId)) {
return;
}

// For each user found in the group, trigger an event (like a notification)
userIds.forEach(function(userId) {
gs.eventQueue('tagged_user.test', incidentRecord, userId, incidentRecord.number.toString());
});

})(current, previous);