Requested Item Comment - comment.user displays as 'undefined'

athavichith
Kilo Sage

When a user post a comment on the requested item, it displays as 'undefined' in the notifications. 

9 REPLIES 9

I added the global prefix and still getting undefined on outgoing notifications

@athavichith 

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.

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

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

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.

Ankur Bawiskar
Tera Patron
Tera Patron

@athavichith 

which user are you referring?

are you able to replicate it?

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