Blog

Incident Review Logging

This article shows an example on how to capture incident views by users. This can be used in many different ways for reporting and monitoring.

This solution doesn't use the Transaction Log, with can be slow to report on due to the size of the table.

Step 1: Create Table

Table Creation

1. Click Left Navigator > System Definition > Tables & Columns
2. Click Create Table
3. Fill in Fields
Label: Task Reviewers
Name: u_task_reviewers
Create Access Controls: true
User Role: admin
4. Click Save
5. Add three additional columns:

  • Action, Choice
  • Reviewer, Reference, User [sys_user]
  • Task, Reference, Task [task]

Step 2: Configure Access Controls

Allow the itil role to view Task Reviewers

Access Control

1. Elevate your role to security admin
2. Click Left Navigator > System Definition > Tables & Columns
3. Find the Task Reviewers table
4. Click the Edit Table button
5. Click the Access Controls tab
6. Click the ACL for read
7. In the Requires Role section, click Edit
8. Add Role: itil
9. Save


Step 3: List Setup

Add Task Reviewers Related List to Incident Form

Incident Related Lists

1. Click Incident > Open
2. Open an Existing Incident
3. Right click Header bar > Personalize > Related Lists
4. Add Task Reviewers > Task
5. Click Save

 

 

 

Task Reviewers List

Customize Task Reviewers List

1. Click Incident > Open
2. Open an Existing Incident
3. Right click the Task Reviewers Related List Header Bar > Personalize > List Layout
4. Add the Created  field
5. Click Save




Step 4: Scripting

Add Script Include for Ajax Reviewer calculation

1. Go to System Definition Script Includes
2. Add this Script Include

Script Include: SetTaskReviewer
Client Callable: true
Script:
var SetTaskReviewer = Class.create();
SetTaskReviewer.prototype = Object.extendsObject(AbstractAjaxProcessor, {
setTaskReviewer: function() {
var grTaskReviewer = new GlideRecord('u_task_reviewers');
grTaskReviewer.u_action = this.getParameter('sysparm_u_action');
grTaskReviewer.u_task = this.getParameter('sysparm_u_task');
grTaskReviewer.u_reviewer = this.getParameter('sysparm_u_reviewer');
grTaskReviewer.insert();
return this.getParameter('sysparm_u_action')+" Set: "+ this.getParameter('sysparm_u_reviewer');
}
});

Add Client Script that captures Reviewer

1. Go to System Definition Script Includes
2. Add this Client Script

Name: Set Task Reviewer
Type: On Load
Table: Incident
Script:
function onLoad() {
var ga = new GlideAjax('SetTaskReviewer');
ga.addParam('sysparm_name','setTaskReviewer');
if (g_form.getValue('assigned_to') == '') {
ga.addParam('sysparm_u_action','Observer');
}
else {
ga.addParam('sysparm_u_action','Reviewer');
}
ga.addParam('sysparm_u_task',g_form.getUniqueValue());
ga.addParam('sysparm_u_reviewer',g_user.userID);
ga.getXML(SetTaskReviewerParse);
function SetTaskReviewerParse(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
//alert(answer);
}
}

Results

Task Reviewers on Incident Form


Notes

  • Testing. After testing this, you may want to adjust the frequency and timing of Task Reviewer logging. You don't want to create a huge amount of updates. Remember this is just an example, you can modify it any way you want.
  • Archive. Another good idea is to archive old task reviews periodically. You could create a scheduled job to do that
  • Other Applications.  You can also add this feature to other applications like Change Management with copies of the client script and add the Task Reviewers related list to the form