Customer Response

ctraspo340
Kilo Contributor

If a ticket is created via My Info Centre form, is there a way to monitor any additional comments or worknotes entered by the sender via a field in the HR case table? 

Looking for a way to create a widget or report based on Additional comments and Work Notes fields

2 REPLIES 2

vaishali231
Kilo Sage

Hey @ctraspo340 

Yes, this is possible.

Both Additional comments and Work notes on HR Cases are journal fields, and their entries are stored in the sys_journal_field table rather than directly as separate records on sn_hr_core_case.

You can create a report, dashboard, or custom widget by querying sys_journal_field with filters like:

For requester comments:

Name = sn_hr_core_case

Element = comments

 

For internal work notes:

Name = sn_hr_core_case

Element = work_notes

 

Useful fields available for reporting:

  1. element_id - HR Case reference
  2. value - comment/work note text
  3. sys_created_by
  4. sys_created_on

If the requirement is specifically to track updates entered by the employee/requester from My Info Centre, filtering on:

Element = comments

 

is usually the best approach, since requester responses normally populate Additional Comments rather than Work Notes.

Example script to retrieve latest requester comments from HR Cases:

var gr = new GlideRecord('sys_journal_field');
gr.addQuery('name', 'sn_hr_core_case');
gr.addQuery('element', 'comments');
gr.orderByDesc('sys_created_on');
gr.query();
while (gr.next()) {
    gs.info('HR Case Sys ID: ' + gr.element_id);
    gs.info('Comment: ' + gr.value);
    gs.info('Created By: ' + gr.sys_created_by);
    gs.info('Created On: ' + gr.sys_created_on);
}


Example Business Rule approach to copy latest comment into the HR Case table for easier reporting:

Table:

sys_journal_field

 

Condition:

 

current.name == 'sn_hr_core_case' &&current.element == 'comments'

Script:

(function executeRule(current, previous) {
    var hrCase = new GlideRecord('sn_hr_core_case');
    if (hrCase.get(current.element_id)) {
        hrCase.u_latest_comment = current.value;
        hrCase.u_last_comment_by = current.sys_created_by;
        hrCase.u_last_comment_date = current.sys_created_on;
        hrCase.update();
    }
})(current, previous);

This approach makes it much easier to build:

      Reports

      PA indicators

     Employee Center widgets

     Dashboards

    SLA tracking based on requester responses

 

*************************************************************************************************************************************

If this response helps, please mark it as Accept as Solution and Helpful.

Doing so helps others in the community and encourages me to keep contributing.

Regards

Vaishali Singh

Servicenow Developer
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb



Hey @ctraspo340 

Hope you are doing well.

Did my previous reply answer your question?

If it was helpful, please mark it as correct ✓ and close the thread . This will help other readers find the solution more easily.

 

Thankyou & Regards

Vaishali Singh

Servicenow Developer
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb