SummaryTableWriter script include

Use the SummaryTableWriter script include to create summary sets for reports that can be generated with standard queries and trending.

The methods involved are described below.
Table 1. SummaryTableWriter script include
Title Description Input parameters Script
SummaryTableWriter (tableName, columnName) Produces a summary set for the COUNT of all incidents grouped by category.
  • tableName: the table used in the query to generate the data.
    Note: The custom chart definition table contains a field named Table that is hidden by default. If the field is set (which it is in some of the base custom charts), then, no matter what is defined within the custom chart scripts, clicking on the chart points you to this table.

    For example, if you create a custom chart against the [task] table through a script, but you copied the custom chart from a custom chart that contains Table = incident, then clicking on any bar in the custom script will go to incident.do rather than to task.do.

    To check the value of the Table field, click the additional actions icon (The additional actions icon) and select Configure > Form Layout and move the Table field from Available to Selected. Open the custom chart definition and set the Table field to none.

  • columnName: the field that is used to determine the X axis values.
var summarySet = new SummaryTableWriter('incident', 'category');
summarySet.generate();
SummaryTableWriter.setQuery(query) Produces a summary set for the COUNT of all active incidents grouped by category.
  • setQuery: The query that was issued to load the data.
var summarySet = new SummaryTableWriter('incident', 'category');
summarySet.setQuery("active=true");
summarySet.generate();
SummaryTableWriter.setStackOn(column) Produces a summary set for the COUNT of all active incidents grouped by category and stacked by priority.
  • column: the column that is used to stack the incident records.
var summarySet = new SummaryTableWriter('incident', 'category');
summarySet.setQuery("active=true");
summarySet.setStackOn('priority');
summarySet.generate();
SummaryTableWriter.setTitle(title) Produces a summary set of the COUNT of incidents that were opened in each month.
  • title: title given to the summary set that is used as the chart title. Also used as the key field for chart generators to determine whether the data was generated.
 
var opened = new SummaryTableWriter('incident', '');
opened.setTitle("Trend of Open Incidents");
opened.setTrend('opened_at', 'month');
opened.generate();
SummaryTableWriter.setTrend(field, interval) Produces a summary set of the COUNT of incidents that were opened in each month. The values for the interval are the same as the values that are provided by the reporting application.
  • field: the time field that is used for X axis values if grouping is not used. If grouping is used, then this is the stacking field.
  • interval: the time interval that is used to calculate the trend.
var opened = new SummaryTableWriter('incident', '');
opened.setTitle("Trend of Open Incidents");
opened.setTrend('opened_at', 'month');
opened.generate();
SummaryTableWriter.generate() Used in all examples above, the generate method actually creates the summary set records.
Additional parameters that can be used:
  • Build Duration: set to indicate how long it took to generate the data.
  • Number: display field for the Summary Set table.