comments in notification

avinashdubey103
Tera Guru

Hi , i  have a  notification that  with below code :

Short description: ${short_description}
Item: ${cat_item}
 
Click here to view request item: ${URI_REF}

${mail_script:attach_links}
Comments:
${comments}

I am not able to understand why it is printing all the comments on the RITM , instead of printing the latest comment only .


ss:


 
avinashdubey103_0-1707375434268.png

 

1 ACCEPTED SOLUTION

SanketLandge1
Kilo Guru

Hello @avinashdubey103 

 

System Properties >> Mail Properties

 

Change the number to 1. It would mean platform wide any notification sent for comments.

 

If you want it to be specific for a table you need mail script & use current.comments.getJournalEntry(1); & then use the mail script in notifications.

find_real_file.png

Change the number to 1. It would mean platform wide any notification sent for comments.

 

If you want it to be specific for a table you need mail script & use current.comments.getJournalEntry(1); & then use the mail script in notifications.

 

View solution in original post

9 REPLIES 9

Ayushi12
Mega Sage

Hi @avinashdubey103 ,

Use the below lines email script

var comment = current.comments.getJournalEntry(1).split('\n')[1];
template.print(comment);

Please mark this response as correct or helpful if it assisted you with your question.

Addy22
Tera Guru

Hi @avinashdubey103 ,

 

If you want to have one comment then you can use below code:

var comment = current.comments.getJournalEntry(1); 

template.print(comment);

 

if you want to do it globally then you can modify this property in Email properties to '1'

AdarshSrivastav_0-1707375966140.png

 

Sarika S Nair1
Kilo Sage

It is showing multiple comments since it is a journal entry field

In order to get latest comment you need to use email script

1. Create an email script by navigating to System Notification --> Email --> Notification Email Script

2. Name it 'getLatestComment' with script as below.

 

 

(function runMailScript(current, template, email, email_action, event) {

    var latestComment= current.comments.getJournalEntry(1);
    template.print(latestComment);

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

 

 

3. Go to notification & add this in appropriate place in notification content section

Comments: ${mail_script:getLatestComment}

Sohail Khilji
Kilo Patron
Kilo Patron

HI @avinashdubey103 

 

Here is the reason :

 

if you use {comments} this will drive all the comments.

if you use  comments.getJournalEntry(1); this will get you the last comments added to the record

if you use comments.getJournalEntry(-1); This will also bring all the comments.

 

recommend you to use the below code :

var com_Rec = current.comments.getJournalEntry(1);
template.print(com_Rec );

 

I hope this helps...

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Yaraslau
Tera Guru

Try ${comments:1} for the last additional comment