Override Comment Username

yaswanth
Tera Contributor

Hi All, i have a requirement that whenever we add a comment, in that comment section field it will show the system default name instead of username and whoever adds the comments then their user name is also not to be shown instead of that it will be the system default name how to achieve this. please help me to avhieve this requirement. Thanks in Advance yaswanth

3 REPLIES 3

Ratna Jyothi P
Tera Expert

  @Yaswanth - To display "System" instead of the user name in ServiceNow comments, use current.comments.setJournalEntry(your comments, 'system') in a business rule

Please refer below posts which might be helpful to override username and display as System.

https://www.servicenow.com/community/itsm-forum/system-added-work-notes-show-user-s-name-instead-of-...

https://www.servicenow.com/community/itsm-forum/show-quot-system-quot-instead-quot-user-name-quot-wh...

Ankur Bawiskar
Tera Patron
Tera Patron

@yaswanth  

so even if some agent adds the comment you want system to be shown?

If yes then I won't recommend doing this and I believe this is not a valid business requirement

How will you determine which comments were added by your agents and which one are from system?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Shivalika
Mega Sage

Hello @yaswanth  

 

Write a before insert BR on sys_journal_entry table - 

(function() {
// Get the current user's name (you can replace this with your desired default name)
var defaultName = "System"; // Or use a specific value from a configuration

// Check if the 'name' field is empty or not
if (current.name == null || current.name == "") {
// Set the 'name' field to the default name
current.name = defaultName;
}
})();

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY