{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":1114,"path":"api-reference/server-api-reference/c_SummaryTableWriter.md","title":"SummaryTableWriter - Global","bundle":null,"doc_type":null,"release":"australia","body":"\n# SummaryTableWriter- Global\n\nThe SummaryTableWriter script include enables the creation of summary sets for reports that can be generated with standard queries and trending.\n\nThis script include provides methods that enable you to customize the output of the summary sets for reports, such as adding a title, defining a query on which to base the report data, and specifying the stack column and X axis.\n\n**Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md)\n\n## SummaryTableWriter - SummaryTableWriter\\(String tableName, String columnName\\)\n\nProduces a summary set for the COUNT of all incidents grouped by category.\n\nThe 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.\n\nFor 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.\n\nTo check the value of the **Table** field, click the additional actions icon and select **Configure** &gt; **Form Layout** and move the **Table** field from **Available** to **Selected**. Open the custom chart definition and set the **Table** field to **none**.\n\n<table id=\"table_tlc_qjv_qx\" class=\"parameters\"><thead><tr><th>\n\nName\n\n</th><th>\n\nType\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\ntableName\n\n</td><td>\n\nString\n\n</td><td>\n\nTable used in the query to generate the data.\n\n</td></tr><tr><td>\n\ncolumnName\n\n</td><td>\n\nString\n\n</td><td>\n\nField that is used to determine the X axis values.\n\n</td></tr></tbody>\n</table>```\nvar summarySet = new SummaryTableWriter('incident', 'category');\nsummarySet.generate();\n```\n\n## SummaryTableWriter - generate\\(\\)\n\nCreates the summary set of records for reports.\n\n|Name|Type|Description|\n|----|----|-----------|\n|None| | |\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar opened = new SummaryTableWriter('incident', '');\nopened.generate();\n```\n\n## SummaryTableWriter - setQuery\\(String query\\)\n\nDefines the query to use to load the data for the summary record set.\n\n|Name|Type|Description|\n|----|----|-----------|\n|query|String|Query to use to load the summary data.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar summarySet = new SummaryTableWriter('incident', 'category');\nsummarySet.setQuery(\"active=true\");\nsummarySet.generate();\n```\n\n## SummaryTableWriter - setStackOn\\(String column\\)\n\nDefines the column on which to stack the incident records.\n\n|Name|Type|Description|\n|----|----|-----------|\n|column|String|Column that is used to stack the incident records.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar summarySet = new SummaryTableWriter('incident', 'category');\nsummarySet.setQuery(\"active=true\");\nsummarySet.setStackOn('priority');\nsummarySet.generate();\n```\n\n## SummaryTableWriter - setTitle\\(String title\\)\n\nSets the title of the summary set, which is also the chart title.\n\n|Name|Type|Description|\n|----|----|-----------|\n|title|String|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.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar opened = new SummaryTableWriter('incident', '');\nopened.setTitle(\"Trend of Open Incidents\");\nopened.setTrend('opened_at', 'month');\nopened.generate();\n```\n\n## SummaryTableWriter - setTrend\\(String field, String interval\\)\n\nSets the time field used for the X axis or stacking field; can also set the time interval used to calculate the trend.\n\n|Name|Type|Description|\n|----|----|-----------|\n|field|String|Time field that is used for X axis values if grouping is not used. If grouping is used, then this is the stacking field.|\n|interval|String|Time interval that is used to calculate the trend.|\n\n|Type|Description|\n|----|-----------|\n|void| |\n\n```\nvar opened = new SummaryTableWriter('incident', '');\nopened.setTitle(\"Trend of Open Incidents\");\nopened.setTrend('opened_at', 'month');\nopened.generate();\n```\n\n"}}