Requested Item Comment - comment.user displays as 'undefined'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 06:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 07:26 AM
I added the global prefix and still getting undefined on outgoing notifications
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 07:50 AM
this line calls the getComments() function.
var comment = notificationUtil.getComments(current.sys_id, 'sc_req_item');
If you look at the function it will set the user only when you pass the 3rd parameter to it i.e. the createdby user name
since you are not sending anything as 3rd parameter it's taking it as undefined.
try this
var comment = notificationUtil.getComments(current.sys_id, 'sc_req_item', '');
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2025 08:01 AM
Hi @athavichith ,
Could you please share the updated script and also let me know in which scope you have created email script.
Best Regards,
Pooja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 08:55 AM
Hello @athavichith
I am not sure how your script include is written when this statement is called:
var comment = notificationUtil.getComments(current.sys_id, 'sc_req_item');
//gs.print(">>>"+comment.user);
Did you tried calling this script include from background script by passing record sys_id and try to see what output you are getting.
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 07:16 AM
which user are you referring?
are you able to replicate it?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader