Notification got triggered to caller but Content (Body) was empty

shubhi211
Tera Guru

when notification is getting triggered, then content i.e. Additional comment is not coming, only work notes is coming. What should be checked?

 

 

Notification which user received:

aa1.png

Notification (what it will contain):

aa2.png

6 ACCEPTED SOLUTIONS

Sumanth16
Kilo Patron

Hi @shubhi211 ,

 

you can use email script and include that email script in email body.

Email script will fetch the latest comments and print it

Something like this

var fieldName = 'comments';

var rec = new GlideRecord('sys_journal_field');
rec.orderByDesc('sys_created_on');
rec.addQuery('name', current.getTableName());
rec.addQuery('element', fieldName);
rec.addQuery('element_id', current.sys_id);
rec.setLimit(1);
rec.query();
if(rec.next()){

template.print("Latest comments: "+ rec.value);

}

If my response helped please mark it correct 

 

Thanks & Regards,
Sumanth Meda

View solution in original post

SN_Learn
Kilo Patron
Kilo Patron

Hi @shubhi211 ,

 

In order to print the comments and work notes, please try the below in notification email script:

 

(function runMailScript(current, template, email, email_action, event) {
	
template.print('WorkNotes: ' + current.work_notes.getJournalEntry(1));
template.print('Comments: ' + current.comments.getJournalEntry(1));
	
})(current, template, email, email_action, event);

 

Mark this as Helpful / Accept the Solution if this helps

 

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

shubhi211
Tera Guru

One question team,

We should not use: ${comments_and_work_notes} ??????

as using ${comments_and_work_notes} the comments should get attached to the email but it is not getting attached to the??? why so

View solution in original post

Hi @shubhi211 ,

 

This is the email script code.

So, you create a notification email script under table [sys_script_email]

Once created that need to be called in the notification as below:

${mail_script:notificationscriptName}

 

Check the below doc for details: Notification Email Scripts 

 

I am not able to find the email script named 'comments_and_work_notes' in PDI so looks like it is custom. Please provide the code of it to debug further. In the meanwhile, you can try the above scripts and call it in notification and test it.

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

Hi @shubhi211 ,

 

Thanks for providing reference:

I have tested it and it is working fine. Please take a look below:

 

SN_Learn_0-1721900597456.png

 

In the notification, defined as below:

SN_Learn_1-1721900631218.png

 

In your incident, please check if there are work notes or comments present or not.

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

shubhi211
Tera Guru

Solution provided by ServiceNow team: 

As work notes and additional comments at a time, in email properties you have mentioned to append on 1 journal entry, that is it is taking only lated journal entry i.e work notes and not appending comments in notification

Solution Proposed:
-- So if there two journal entries at a time, if you want include two entries in notification you can update "Number of journal entries" in email properties.
Email properties

at.png

View solution in original post

10 REPLIES 10

This script should be added under "What it will contain" ?? please let me know

And 

We should not use: ${comments_and_work_notes} ??????

as using ${comments_and_work_notes} the comments should get attached to the email but it is not getting attached to the??? why so

Hi @shubhi211 ,

 

This is the email script code.

So, you create a notification email script under table [sys_script_email]

Once created that need to be called in the notification as below:

${mail_script:notificationscriptName}

 

Check the below doc for details: Notification Email Scripts 

 

I am not able to find the email script named 'comments_and_work_notes' in PDI so looks like it is custom. Please provide the code of it to debug further. In the meanwhile, you can try the above scripts and call it in notification and test it.

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

shubhi211
Tera Guru

One question team,

We should not use: ${comments_and_work_notes} ??????

as using ${comments_and_work_notes} the comments should get attached to the email but it is not getting attached to the??? why so

shubhi211
Tera Guru

Notification variables (servicenow.com)

 

Please refere: ${comments_and_work_notes:n}

Hi @shubhi211 ,

 

Thanks for providing reference:

I have tested it and it is working fine. Please take a look below:

 

SN_Learn_0-1721900597456.png

 

In the notification, defined as below:

SN_Learn_1-1721900631218.png

 

In your incident, please check if there are work notes or comments present or not.

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.