- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2025 04:02 PM
Hi Community,
I need to create a quick message for the P1/P2 incidents to show all the work notes have been added to this incident so far. In the quick message, I use ${work_notes} to pull the variable but the maximum work notes number that listed in the quick message is 3. It always shows the latest 3 work notes of this incident. How to show all the work notes in the quick message?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2025 06:17 PM
Hi @ShuRiseUp2023 ,
1. you can set the system property value to -1
glide.email.journal.lines
note: this would be reflecting in all over the system
2. else follow this approach
create a Before insert update BR on the sys_email and sys_email_draft table
with script
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var targetRecord = new global.GlideRecordUtil().getGR(current.getValue('target_table'), current.getValue('target_record'));
if (targetRecord.isValidRecord()) {
current.setValue('body', current.getValue('body').replaceAll('{placeHolderWorknotes}', targetRecord.work_notes.getJournalEntry(-1)).replaceAll('\n','<br/>'));
}
})(current, previous);
add the key Word {placeHolderWorknotes} in whichever the quick message you want
The BR parses it and replaces it with the worknotes
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2025 06:06 PM - edited ‎07-15-2025 06:07 PM
Hi @ShuRiseUp2023 ,, Good morning,.....!
When you use ${work_notes} in your quick message or notification, ServiceNow by default only pulls the last three work notes — that’s controlled internally by how the notification formatter works, and there isn’t a simple system property to change it.
If you really want to include all work notes, the recommended way is to create a mail script that manually queries the sys_journal_field table for that incident and builds the list yourself.
xample of what that mail script
// Mail script to get all work notes
(function runMailScript(current, template, email, email_action, event) {
var notes = '';
var gr = new GlideRecord('sys_journal_field');
gr.addQuery('element_id', current.sys_id); // link to the incident
gr.addQuery('element', 'work_notes'); // only work notes
gr.orderBy('sys_created_on'); // oldest first
gr.query();
while (gr.next()) {
notes += '- ' + gr.sys_created_on.getDisplayValue() + ': ' + gr.value + '\n';
}
template.print(notes);
})(current, template, email, email_action, event);
quick message, instead of ${work_notes}, insert
${mail_script:your_script_name}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2025 07:08 PM
Thank you for your response. I have first tried use mail script, but it seems like not working in quick message. it's ignored.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2025 06:17 PM
Hi @ShuRiseUp2023 ,
1. you can set the system property value to -1
glide.email.journal.lines
note: this would be reflecting in all over the system
2. else follow this approach
create a Before insert update BR on the sys_email and sys_email_draft table
with script
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var targetRecord = new global.GlideRecordUtil().getGR(current.getValue('target_table'), current.getValue('target_record'));
if (targetRecord.isValidRecord()) {
current.setValue('body', current.getValue('body').replaceAll('{placeHolderWorknotes}', targetRecord.work_notes.getJournalEntry(-1)).replaceAll('\n','<br/>'));
}
})(current, previous);
add the key Word {placeHolderWorknotes} in whichever the quick message you want
The BR parses it and replaces it with the worknotes
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2025 08:08 PM
Thank you so much for your response. I tried exactly the same as you descripted here. but still not working. In your BR,
Then I checed the sys_email table and found out we should use instance instead of target_record. in sys_email table,
var targetRecord = new global.GlideRecordUtil().getGR(current.getValue('target_table'), curent.getValue('instance'));
Thank you so much