Embedding reports in Jelly
You can embed reports in any Jelly-based element, such as a UI page.
Enabling Embedding
To enable embedding reports in Jelly, add the following element to your Jelly code.
<g:inline template="reporting_includes.xml" />
After adding this code, you can embed an existing report, or generate a report within the Jelly code.
Embedding an existing report
You can embed an existing report by calling the embedReportById(targetSpan, reportId) function.
For example, add the following to the HTML/XML block in the UI page record:
<xml version="1.0" encoding="utf-8">
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:inline template="reporting_includes.xml" />
<div id="report_stuff" />
</j:jelly>
And add the following to the Client script block in the UI page record. Replace <report sys_id> with the report's actual sys_id:
var div = $j("#report_stuff");
embedReportById(div, <"report sys_id">);
Alternatively, you can embed the JavaScript in the jelly code entirely in the HTML/XML block. Add the code from the client script block between <script> tags:
<xml version="1.0" encoding="utf-8">
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:inline template="reporting_includes.xml" />
<div id="report_stuff" />
<script>
var div = $j("#report_stuff");
embedReportById(div, <"report sys_id">);
</script>
</j:jelly>
| Parameter | Description |
|---|---|
| targetSpan | The jQuery element to embed the chart in. The chart uses the size of this element. |
| reportId | The sys_id of the report you want to embed. |
Generate and embed a report
You can embed a report within the UI by calling the embedReportByParams(targetSpan, parms) function. When embedding a report in this way, you can generate a new report using parameters, or specify a report sys_id to display that report.
For example, add the following to the HTML/XML block in the UI page record:
<xml version="1.0" encoding="utf-8">
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:inline template="reporting_includes.xml" />
<div id="report_stuff" />
</j:jelly>
And add the following to the Client script block in the UI page record:
var params = {sysparm_title: "Average for all ratings", sysparm_field: "category", sysparm_type: "bar", sysparm_table: "asmt_category_result", sysparm_aggregate: "AVG", sysparm_sumfield: "rating"};
var div = $j("#report_stuff");
embedReportByParams(div, params);
Alternatively, you can embed the JavaScript inside the jelly code. Add the code from the client script block between <script> tags:
<xml version="1.0" encoding="utf-8">
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:inline template="reporting_includes.xml" />
<div id="report_stuff" />
<script>
var params = {sysparm_title: "Average for all ratings", sysparm_field: "category", sysparm_type: "bar", sysparm_table: "asmt_category_result", sysparm_aggregate: "AVG", sysparm_sumfield: "rating"};
var div = $j("#report_stuff");
embedReportByParams(div, params);
</script>
</j:jelly>
| Parameter | Description |
|---|---|
| targetSpan | The jQuery element to embed the chart in. |
| parms | A JSON object defining the report. Available parameters depend on the report type. |
Generating and embedding a list report
When you embed an existing list report or generate a list report and embed it, you must enter one more line of code.
Add the following to the HTML/XML block in the UI page record:
<xml version="1.0" encoding="utf-8">
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:inline template="reporting_includes.xml" />
<g:inline template="list2_js_includes.xml" />
<div id="report_stuff" />
</j:jelly>
Add the following to the Client script block in the UI page record. Replace <report sys_id> with the report's actual sys_id:
var div = $j("#report_stuff");
embedReportById(div, <"report sys_id">);
Or embed the JavaScript in the jelly code entirely in the HTML/XML block. Add the code from the client script block between <script> tags:
<xml version="1.0" encoding="utf-8">
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:inline template="reporting_includes.xml" />
<g:inline template="list2_js_includes.xml" />
<div id="report_stuff" />
<script>
var div = $j("#report_stuff");
embedReportById(div, <"report sys_id">);
</script>
</j:jelly>
| Parameter | Description |
|---|---|
| targetSpan | The jQuery element to embed the chart in. The chart uses the size of this element. |
| reportId | The sys_id of the report you want to embed. |
Parent Topic:Advanced Core UI reporting topics
Embedded report parameters
When embedding a report in a Jelly element, you can define a report at any time by passing parameters.
Common parameters
Certain parameters are used by multiple report types.
| Parameter | Description | Default value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| jvar\_report\_id | The sys\_id of a report record. If you pass this parameter, do not specify any other parameters. All values are taken from the report record. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sysparm\_report\_id | Use this parameter instead of jvar\_report\_id when you want to override any of the other sysparm parameters that exist in the report. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sysparm\_title | The title of the report. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sysparm\_table | The table to report on. Specify this value or sysparm\_report\_source\_id, but not both. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sysparm\_report\_source\_id | The sys\_id of a report source. Specify this value or sysparm\_table, but not both. This value is used instead of sysparm\_table if you pass both. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sysparm\_type | The type of report to create. Possible values: list, line, line\_bar, area, spline, bar, horizontal\_bar, pareto, hist, pie, donut, semi\_donut, speedometer, dial, pivot, pivot\_v2, funnel, calendar, pyramid, box, trend, control, trendbox, and heat map. | line | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sysparm\_field | The field from the specified table to group data by. Required for time series, column, bar, pie, donut, funnel, pyramid, box, trend, and trendbox reports. Optional for list reports. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sysparm\_query | The filter to apply to the data before generating the report. Specify a query string for this value. To sort your query results by a specific field, add `^ORDERBY| | sysparm\_aggregate | The aggregation type.Possible values: AVG, COUNT, SUM, and COUNT\_DISTINCT | COUNT | sysparm\_sumfield | The field to aggregate data on. This parameter does not apply when using a COUNT aggregation type. | | sysparm\_display\_grid | A true/false value that controls whether the report displays a data grid. | false | sysparm\_show\_other | A true/false value that controls whether the Other group appears on the report. This group appears only if the number of groups exceeds the number specified in the sysparm\_others parameter. This parameter applies to bar, pie, funnel, pyramid, pivot, and heat map reports. | true | sysparm\_others | The maximum number of individual groups of data to display. Any additional data groups are combined into the Other group. This parameter applies to bar, pie, funnel, pyramid, pivot, and heat map reports. | | sysparm\_source\_type | The source of the embedded report. Optional.Possible values: table, metricbase, source, import | table | sysparm\_set\_color | The color setting for the report.Possible values: one\_color, color\_palette, several\_colors | color\_palette | sysparm\_color\_palette | The color palette that the report uses. This parameter is used when sysparm\_set\_color="color\_palette".Possible value: The sys\_id of a color palette | Default UI14 | sysparm\_color | The color that the report uses. This parameter is used when sysparm\_set\_color="one\_color".Possible value: The sys\_id of a color | | sysparm\_chart\_colors | The set of chart colors that the report uses. This parameter is used when sysparm\_set\_color="several\_colors".Possible value: A comma-separated list of color hex codes | | sysparm\_show\_marker | A marker is the value represented by a dot in a line or another graphic element in a chart. This parameter is a true/false value that controls whether the marker appears. | true | sysparm\_show\_empty | A true/false value that controls if records with empty grouping or trend values appear on the report. | false | sysparm\_stack\_field | The field used to control stacking on bar and column reports. | | sysparm\_bar\_unstack | A true/false value that controls if stacked data is presented as a single bar or column, or as multiple bars. | false | sysparm\_box\_field | The numeric field used to measure the data. This parameter is required for box and histogram reports. | | sysparm\_trend\_field | The date-time field used to organize trend data. This parameter is required for time series, trend, and box reports. | | sysparm\_trend\_interval | The interval to measure trend values by. Possible values: year, quarter, month, week, dayofweek, hour, and date. | year | sysparm\_compute\_percent | The value to use when displaying report percentages. You can display percentages based on the total record count, or by the specified aggregate.Possible values: aggregate and count | count | sysparm\_funnel\_neck\_percent | A number 1–100 that defines the percentage of a funnel report that is the neck of the funnel. | 30 | sysparm\_show\_chart\_data\_label | A true/false value that controls if data labels appear on the report. | false | sysparm\_show\_zero | A true/false value that controls if zeroes appear on multilevel pivot and heat map reports. | | sysparm\_ct\_row | The field used to define the rows in heat map and bubble reports. | | sysparm\_ct\_column | The field used to define the columns in heat map and bubble reports. | | sysparm\_y\_axis\_category\_fields | The field used to define the rows in multilevel pivot reports. Specify up to five comma-separated field names. | | sysparm\_x\_axis\_category\_fields | The field used to define the columns in multilevel pivot reports. Specify up to three comma-separated field names. | | sysparm\_list\_ui\_view | The sys\_id of a list view to use when a user drills into the report. | | sysparm\_show\_marker | A true/false value that controls if markers appear at every plotted point on a report. | true | sysparm\_apply\_alias | A true/false value that controls if configured aliases appear in embedded reports. | | Service catalog parametersCertain parameters apply only to reports created on service catalog tables, such as the Requested Item [sc_req_item] table. These parameters are not available on list or calendar type reports.
MetricBase parametersTo use MetricBase in an embedded report, the sysparm_source_type parameter must be set to "metricbase". MetricBase also requires the sysparm_custom_configuration parameter, which has the following syntax: In this syntax:
All attributes are required except for Chart-specific parametersCertain parameters are available only for specific report types.
Chart size parametersCertain parameters control the width and height of the report.
Chart title parametersCertain parameters are available only for reports that display a title. These report types include time series, bar, column, pie, donut, dials, trend, box, trend box, histogram, pyramid, heat map, funnel, and control reports.
Chart border parametersCertain parameters are available only for reports that display a border. These report types include: time series, bar, column, pies, donuts, dials, trend, box, trend box, histogram, pyramid, heat map, funnel, and control reports.
Legend parametersCertain parameters are available only for reports that display a legend. These report types include pie, donut, stacked bar, stacked column, time series, trend, box, histogram, pyramid, control, and heat map reports.
X-axis parametersCertain parameters are available only for reports that use an X axis. These report types include bar, horizontal bar, pareto, column, line area, spline, box, trendbox, control, and trend reports.
Y-axis parametersCertain parameters are available only for reports that use a Y axis. These report types include bar, horizontal bar, Pareto, column, line area, spline, box, trendbox, control, and trend reports.
|