- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 10:57 PM
Hi , i have a notification that with below code :
I am not able to understand why it is printing all the comments on the RITM , instead of printing the latest comment only .
ss:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 11:04 PM
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 11:04 PM - edited 02-07-2024 11:06 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 11:07 PM
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'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 11:08 PM - edited 02-07-2024 11:11 PM
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}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 11:08 PM
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....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2025 06:53 AM
Try ${comments:1} for the last additional comment