Customizing the columns in Dovetail Agent console
One of the common customization in Dovetail Agent is changing the columns that are shown in the console. Columns are typically added, removed, or reordered, depending on the business requirements and workflow of a company.
In Dovetail Agent 4.3, the columns can be sorted dynamically by each user, and changes have been made to improve performance of the console by returning pages of records instead of all the records in a queue or wipbin. In Dovetail Agent 4.4 the process of getting the data has been improved, but is very similar in how the code is customized.
Since customizing the columns is a common task during implementation of Dovetail Agent, going through the process here as a reference should help future endeavors.
There are three pages that need to be changed to customize the columns in the console:
-
console/getConsoleRecords.asp
-
console/getConsoleRecordToRefresh.asp
-
console/console_main.asp
Customizing getConsoleRecords.asp
At the top of the getConsoleRecords.asp page, the following line reflects the columns that will be shown in the console. The first item represents the select checkbox column, and the rest represent the column items.
var columnList = ["select", "type", "id", "condition", "status", "severity", "priority", "title", "seconds"];
Changing this array declaration is the first step for the customization. For this study, the changes are as follows:
var columnList = ["select", "type", "id_number", "age", "condition", "status", "priority", "alt_first_name", "alt_last_name", "title", "severity"];
Comparing the two arrays, the differences are adding first name and last name, and rearranging some of the others. Not all of the data is on every view, but empty cells in the console are acceptable in those situations. The order of the columns is important, since the column sorting used is based on the column position. Changes to the views need to be made if the data is not already included in the views used for the console. In the baseline view, the contact name fields are not included on the views used for the console records. To add the columns in this customization, joins were added to the queelm and wipelm view for both case and subcase.
Each of the six objects (cases, subcases, solutions, action items, part request details, and change requests) included in the console records is queried, and then the records for each object are processed and added to an array of records to be displayed. For each object, a JSON object is created to hold the object details. The baseline case records are processed as shown here:
while(boCaseView.EOF != true) {
var record = {};
record.object_type = 0;
record.id_number = boCaseView("id_number") + "";
record.status = boCaseView("status") + "";
record.priority = boCaseView("priority") + "";
record.severity = boCaseView("severity") + "";
record.condition = boCaseView("condition") + "";
record.title = boCaseView("title") + "";
record.age = formatDate(new Date(boCaseView("age").value), "MM/dd/yyyy HH:mm:ss");
record.elm_objid = boCaseView("elm_objid").value;
record.id = boCaseView("id_number") + "";
record.id = record.id.toLowerCase().replace("-",".");
record.seconds = new Date(boCaseView("age").value).getTime();
record.seconds = record.seconds * -1;
record.type = "case";
records.push(record);
boCaseView.MoveNext();
}
The following two lines are added to the case record processing to get the data added to the array:
record.alt_first_name = boCaseView("contact_first_name") + "";
record.alt_last_name = boCaseView("contact_last_name") + "";
This same change is done for the subcase records, and the other four objects get the following two lines added so the corresponding columns will be empty:
record.alt_first_name = "";
record.alt_last_name = "";
Customizing getConsoleRecordToRefresh.asp
The getConsoleRecordToRefresh.asp page is called from console_main.asp each time a record needs to be added to, updated in, or removed from the console grid. Adding and updating end up doing the same thing, so it just comes down to two paths to follow in the code.
For removing records, nothing needs to be customized since the row is going away. A JSON object is created to be processed, but its action is just set to “remove”.
When adding or updating though, the JSON object that gets produced needs to have properties defined for all of the columns represented in the console. In this example, the first and last name properties are defaulted to empty strings, and filled in only for case and subcase objects. The changes for the contact name fields are shown here mixed in with the baseline code:
record.action = "update";
record.age = boConsoleObject("age") + "";
record.condition = boConsoleObject("condition") + "";
record.title = boConsoleObject("title") + "";
record.contact_first_name = "";
record.contact_last_name = "";
if(strElmType == "case" || strElmType == "subcase") {
record.severity = boConsoleObject("severity") + "";
record.contact_first_name = boConsoleObject("contact_first_name") + "";
record.contact_last_name = boConsoleObject("contact_last_name") + "";
} else {
record.severity = "";
}
Customizing console_main.asp
For the console_main.asp page, the column list is duplicated near the top of the page. The column names and order should match exactly.
In the create_row function, the data for each row needs to be modified to represent the correct column order, and the new columns get added as table cells there as well. Notice the two lines for the contact’s first name and last name below:
function createRow(rowData, checkbox_num) {
var object = getObjectType(rowData.object_type);
var rowId = object.Type + rowData.id_number;
var row = $("<tr id=’" + rowId + "’ chk=0 class=’consoleRow " + rowData.object_type + "’ title=’" + object.Name + " " + rowData.id_number + "’>")
.append("<td width=’10px’><input type=’checkbox’ class=’selectBox’ order=’" + checkbox_num + "’ id=’" + object.Type + "|" + rowData.id_number + "’ onclick=’selectRow(this);’/></td>")
.append("<td>" + object.Name + "</td>")
.append("<td class=’idCell’ onclick=’OpenObjectWithObjid(" + rowData.object_type + "," + rowData.elm_objid + ");’>" + "<a href="=" + object.Name + " " + rowData.id_number + "|" + rowData.condition + "|" + rowData.elm_objid + "|" + rowData.id_number + "">" + rowData.id_number + "</a></td>")
.append("<td>" + getAge(rowData.age) + "</td>")
.append("<td>" + rowData.condition + "</td>")
.append("<td>" + rowData.status + "</td>")
.append("<td>" + rowData.priority + "</td>")
.append("<td>" + rowData.contact_first_name + "</td>")
.append("<td>" + rowData.contact_last_name + "</td>")
.append("<td>" + rowData.title + "</td>")
.append("<td>" + rowData.severity + "</td>");
$(row).data("details", rowData);
return row;
}
The html also needs to be modified to show the correct column order. In the body of the page, the console table is defined with a thead section and an empty tbody section. The thead gets modified to show the new columns and their order:
<table id="consoleMainTable">
<thead>
<tr>
<th id="selectAll" title="Select/Unselect All">Select</th>
<th id="type" >Type</th>
<th id="id_number">ID Number</th>
<th id="age">Age(d h:m)</th>
<th id="condition">Condition</th>
<th id="status" >Status</th>
<th id="priority" >Priority</th>
<th id="contact_first_name">First Name</th>
<th id="contact_last_name">Last Name</th>
<th id="title" >Title</th>
<th id="severity" >Severity</th>
</tr>
</thead>
<tbody></tbody>
</table>
That is everything that needs to get changed. The new console is much faster, and the multiple column sorting can be very useful. Customizing Dovetail Agent is always challenging, so be sure to send me any questions if help is needed.