Display Group Name Instead of User Name on Comments/Updates
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2025 02:42 PM
I want to create a group, and whenever any member of that group posts an update such as a comment or activity it should display the Group Name instead of the individual member’s name. This way, all actions appear to be performed by the group collectively rather than by specific users
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2025 10:06 PM - edited ‎05-15-2025 10:07 PM
Hello @MakhanlalM,
To make group updates appear under the group name instead of individual member names in ServiceNow, you'll need to modify the
sys_history_line
table to display the group name instead of the user's name for all comments and activities.
Please refer to the below steps:
- Create a Business Rule:
- Navigate to System Definition > Business Rules.
- Create a new Business Rule.
- Set the following:
- Name:
Display Group Name on Comments
- Table:
sys_history_line
- When:
Before
- Insert:
insert
- Business Rule Type:
Before
- Name:
- Add the following script in the Script (Business Rule) field:
function getGroupFromUser(user) {
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', user);
gr.query();
if (gr.hasNext()) {
while (gr.next()) {
return gr.group;
}
}
return null;
}
function getGroupName(group) {
var gr = new GlideRecord('sys_user_group');
gr.addQuery('sys_id', group);
gr.query();
if (gr.hasNext()) {
while (gr.next()) {
return gr.name;
}
}
return null;
}
if (current.table == "sys_history_line") {
var user = current.user;
var group = getGroupFromUser(user);
if (group != null) {
var groupName = getGroupName(group);
if (groupName != null) {
current.setValue("user", groupName);
}
}
}
If it is helpful, please mark it as helpful and accept the correct solution, By refer to this solution, it will helpful to them
.
Thanks & Regards,
Abbas Shaik