How to update comments or work notes in incidents in UI Action?

Laida Garcia
Kilo Explorer

Hi. I am trying to update the value of all comments and work notes using button in UI action. But instead of updating it just added. Ex. change  'Sample123' to  'Sample Text Change'find_real_file.pngfind_real_file.png

6 REPLIES 6

after trying this. we are redirecting to this page

find_real_file.png

John Dahl
Tera Guru

I think you have the answers you need, but to be clear... the comments and work_notes fields on the incident GlideRecord are only there for input. Once you save the record, the content is moved into a new record in the sys_journal_field table. So any changes to existing records need to be made there. Any NEW comments that you want to add can be made to the Incident GlideRecord fields.

 

To update the existing entries for a specific record, you need to query the sys_journal_field table where element_id field on the journal entry matches the sys_id of the incident record. As a side note, once you have the incident as current, you do not need to query the database for the record.



var grEntry = new GlideRecord( 'sys_journal_field' );
grEntry.addQuery( 'element_id', current.getUniqueValue() );
grEntry.query();

while( grEntry.next() ){

  grEntry.value = 'whatever you want the new entry to say';
  grEntry.update();

}