How to get the latest worknotes value
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 12:06 AM - edited 06-07-2024 12:08 AM
Hi All,
How to get the latest worknotes value(Information),
I tried with the background script like below and I got the latest value through background script as I expected,
var workNotes = " ";
var workNotesGR = new GlideRecord('sys_journal_field');
workNotesGR.addQuery('element_id', 'b9c5b5ee872a06d0c461fdd7cebb35df');
workNotesGR.addQuery('element', 'work_notes');
workNotesGR.orderByDesc('sys_created_on');
workNotesGR.orderBy('sys_created_on');
workNotesGR.query();
if(workNotesGR.next()) {
workNotes = workNotesGR.getValue('value');
gs.log("worknotesvinuth18" +workNotes);
}
Updated latest worknote as "test4" and through background script get the same value.
Same script I tried in the before update Business rule but it's not working as expected (and I am getting the last but one value in the logs)
var taskGR = new GlideRecord('sc_task');
taskGR.addQuery('number', current.number);
taskGR.query();
while (taskGR.next()) {
var assign=taskGR.assigned_to.getDisplayValue();
gs.log("testvinuth9 "+assign);
var workNotes = '';
var workNotesGR = new GlideRecord('sys_journal_field');
workNotesGR.addQuery('element_id', taskGR.sys_id);
workNotesGR.addQuery('element', 'work_notes');
workNotesGR.orderByDesc('sys_created_on');
workNotesGR.orderBy('sys_created_on');
workNotesGR.query();
if(workNotesGR.next()) {
workNotes = workNotesGR.getValue('value');
gs.log("worknotesvinuth18" +workNotes);
}
Here I am getting the test2 instead of test3 value in the worknotes.
Please any one suggest me how to get the latest updated work notes value(Information) from the Business Rule.
Thanks in advance,
Vinuth
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 12:09 AM
Hi @vinuth v
refer to the below code.
var notes = current.work_notes.getJournalEntry(-1); // -1 for all the work notes value , 1 for latest work notes value
var notes = current.comments.getJournalEntry(-1);
If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.
Thanks
dgarad
Thanks
dgarad