Notification email System user show as undefined

dustinjones
Tera Expert

Hello,

 

I have a flow that updates the RITM with an additional comment. The ticket itself show the comment being made by SYSTEM but the notification email show the comment being made by UNDEFINED. Any thoughts?

 

Thanks

1 ACCEPTED SOLUTION

AnnMarieC
Tera Guru

Hi @dustinjones - I ran into the same issue. The user is getting set in the RequestNotificationUtilSNC script include. However SN provides the RequestNotificationUtil script include to write override functions if needed. So I copied the getComments function and modified where it sets the user. We just needed to replace it with Service Desk just so it didn't say undefined. So I updated the last section to the following:

 

if (!byUserName) {
   var userRec = new GlideRecord('sys_user');
   userRec.addQuery('user_name', journalRec.sys_created_by);
   userRec.setLimit(1);
   userRec.query();
   if (userRec.next()) {
      comment.user = userRec.name;
   } else if(journalRec.sys_created_by == 'system'){
      comment.user = "Service Desk"; //Replace this with the name you want to use
   }
}

 

 

View solution in original post

8 REPLIES 8

Mohith Devatte
Tera Sage
Tera Sage

HELLO @dustinjones ARE YOU USING EMAIL SCIRPT TO PRINT THE COMMENTS IN THE NOTIFICATION? 

 

If yes please send the script here

dustinjones
Tera Expert

Hello, 


Yes, it is the default OOB "comment_left_request" script. My assumption is comment.user is looking at the user table and SYSTEM doesn't exist but learning as I go so not sure if that is true or best way to fix.

 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
	/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
	/* Optional GlideRecord */ event) {

	var width = 'width: 100%;';
	var fontSize = 'font-size: 16px;';
	var lineHeight = 'line-height: 24px;';
	var paddingTop = 'padding-top: 16px;';
	var marginBottom = 'margin-bottom: 16px;';
	var notificationUtil = new RequestNotificationUtil();
	var comment = notificationUtil.getComments(current.sys_id, 'sc_req_item');
	var salutation = notificationUtil.setGreetingsMessage(current, email_action);
	var portalSuffix = new sn_ex_emp_fd.FoundationNotificationUtil().getPortalSuffix();
	var uri = gs.getProperty('glide.servlet.uri') + portalSuffix +'?id=ticket&table=' + current.sys_class_name + '&sys_id=' + current.sys_id;
	var catalogItemJS = new sn_sc.CatItem(current.cat_item);
	var catItemDetails = catalogItemJS.getItemSummary(true);
	var desc = catItemDetails.name.toString();

	template.print('<div style="font-size: 24px; line-height: 36px; text-align: center; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid #DADDE2;">' + comment.user + ' added a comment to your request</div>');
	template.print('<div style="' + width + fontSize + lineHeight + '">'+ salutation + '</div>');
	template.print('<div style="' + width + fontSize + lineHeight + paddingTop + '">' + comment.user + ' left a comment on <span style="font-weight: 600;">' + current.number + ':</span></div>');
	template.print('<div style="' + width + fontSize + lineHeight + paddingTop + marginBottom + '"><span style="font-weight: 600;">"' + comment.val + '"</span></div>');
	notificationUtil.createNotificationPrimayAction(template, uri, 'View comments');
	template.print('<div style="font-size: 20px; line-height: 30px; font-weight: 600; margin-bottom: 16px;">About this request</div>');
	template.print('<div style="' + fontSize + lineHeight + '"><span>Request number: </span><span style="font-weight: 600;">' + current.number + '</span></div>');
	template.print('<div style="' + fontSize + lineHeight + ' margin-bottom: 16px;"><span>Short description: </span><span style="font-weight: 600;">' + desc + '</span></div>');

})(current, template, email, email_action, event);

 

@dustinjones i guess system user is not present in your user data base .

 

Did you double check in user table  ?

 

And also in the comments field whats the name it shows when a comment is posted ?

 

 

dustinjones
Tera Expert

@Mohith Devatte when i look at the users in my instance System doesn't exist.

 

On the RITM the comment is posted by System.