Is there a way to combine Incident comments and work notes so they appear chronologically in a notification?

drew_plastridge
Kilo Contributor

I am able to display both work notes and comments in a notification (see below).   However, they display separately and I would like to combine them so they display like in the notes tab of the incident.

Incident: ${URI_REF} has been assigned to you

Description: ${short_description}
Category: ${category}
CI: ${cmdb_ci.name}
Caller: ${caller_id}
Priority: ${priority}

Work Notes:
${work_notes}

Previous Comments:
${comments}

1 ACCEPTED SOLUTION

I think i misunderstood the question.


For showing both additional comments and work notes in chronological order, you need to query sys_journal_field table where these additional comments and work notes are stored actually.   You will have to use email script to query to this table, look for all comments and worknotes assocaited with current incident, sort it based on updated date time , and get the values



find_real_file.png


View solution in original post

4 REPLIES 4

Deepak Ingale1
Mega Sage

Hi Drew,



An HTML table inside the notification will help you to show info in to columns of the table.


Hi Deepak,


I think I missing something.   How would you get the Work Notes and Comments to combine using an HTML table?



Thanks,
Drew


I think i misunderstood the question.


For showing both additional comments and work notes in chronological order, you need to query sys_journal_field table where these additional comments and work notes are stored actually.   You will have to use email script to query to this table, look for all comments and worknotes assocaited with current incident, sort it based on updated date time , and get the values



find_real_file.png


That works perfectly, here is the query I used:



var notes = new GlideRecord('sys_journal_field');


notes.addQuery('element_id', 'current.sys_id');


notes.query();


notes.orderByDesc('sys_created_on')


while (notes.next()){


        gs.info(notes.element + ": " + notes.sys_created_on + ": " + notes.value);


}