- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2019 11:34 AM
Hi
How to get the last work note of the incident and add it to the
short description of the incident
Need Help!!!
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 12:23 AM
Hello JHON,
You can use the code given by sachin as well but it will give output as :
2019-07-12 00:21:08 - System Administrator (Work notes)Code for work note update
My approach is as below:
1. You can create a AFTER UPDATE Business Rule with below configuration.
2. Scrip in Business Rule:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var grInc = new GlideRecord('sys_journal_field');
grInc.addQuery('element_id',current.sys_id); // Adding filter to find current incident
grInc.addQuery('element','work_notes'); // Adding filter to fetch only Worknotes
grInc.orderByDesc('sys_created_on');
grInc.query();
grInc.next();
current.short_description = grInc.value ;
current.setWorkflow(false); // Stop Running Business rule recursively as we have used current.udpate();
current.update();
})(current, previous);
Please mark answer correct if you found it as helpful.
Thanks,
Abhishek
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2019 03:43 PM
you can write business rule to get last work note and add to short description
you can use below script
current.short_description = current.work_notes.getJournalEntry(-1); // -1 for all the work notes value , 1 for latest work notes value
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2019 12:23 AM
Hello JHON,
You can use the code given by sachin as well but it will give output as :
2019-07-12 00:21:08 - System Administrator (Work notes)Code for work note update
My approach is as below:
1. You can create a AFTER UPDATE Business Rule with below configuration.
2. Scrip in Business Rule:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var grInc = new GlideRecord('sys_journal_field');
grInc.addQuery('element_id',current.sys_id); // Adding filter to find current incident
grInc.addQuery('element','work_notes'); // Adding filter to fetch only Worknotes
grInc.orderByDesc('sys_created_on');
grInc.query();
grInc.next();
current.short_description = grInc.value ;
current.setWorkflow(false); // Stop Running Business rule recursively as we have used current.udpate();
current.update();
})(current, previous);
Please mark answer correct if you found it as helpful.
Thanks,
Abhishek
Abhishek Gardade